diff --git a/cmd.go b/cmd.go index 7254b7e..804d828 100644 --- a/cmd.go +++ b/cmd.go @@ -31,8 +31,9 @@ type PeriodicConfig struct { CmdFunc func(channel string) (string, error) // func to be executed at the period specified on CronSpec } -// User holds user id (nick) and real name +// User holds user id, nick and real name type User struct { + ID string Nick string RealName string } diff --git a/irc/irc.go b/irc/irc.go index ec94911..22c6bc8 100644 --- a/irc/irc.go +++ b/irc/irc.go @@ -37,7 +37,10 @@ func responseHandler(target string, message string, sender *bot.User) { } func onPRIVMSG(e *ircevent.Event) { - b.MessageReceived(e.Arguments[0], e.Message(), &bot.User{Nick: e.Nick}) + b.MessageReceived(e.Arguments[0], e.Message(), &bot.User{ + ID: e.Host, + Nick: e.Nick, + RealName: e.User}) } func getServerName(server string) string { diff --git a/slack/slack.go b/slack/slack.go index bab71db..9e2ba6f 100644 --- a/slack/slack.go +++ b/slack/slack.go @@ -27,7 +27,10 @@ func extractUser(userID string) *bot.User { fmt.Printf("Error retrieving slack user: %s\n", err) return &bot.User{Nick: userID} } - return &bot.User{Nick: slackUser.Name, RealName: slackUser.Profile.RealName} + return &bot.User{ + ID: userID, + Nick: slackUser.Name, + RealName: slackUser.Profile.RealName} } func readBotInfo(api *slack.Client) { diff --git a/telegram/telegram.go b/telegram/telegram.go index 6cec969..5283fe2 100644 --- a/telegram/telegram.go +++ b/telegram/telegram.go @@ -4,6 +4,7 @@ package telegram import ( "log" "strconv" + "strings" "github.com/go-chat-bot/bot" "gopkg.in/telegram-bot-api.v3" @@ -52,7 +53,11 @@ func Run(token string, debug bool) { for update := range updates { target := strconv.FormatInt(update.Message.Chat.ID, 10) - sender := strconv.Itoa(update.Message.From.ID) - b.MessageReceived(target, update.Message.Text, &bot.User{Nick: sender}) + name := []string{update.Message.From.FirstName, update.Message.From.LastName} + + b.MessageReceived(target, update.Message.Text, &bot.User{ + ID: strconv.Itoa(update.Message.From.ID), + Nick: update.Message.From.UserName, + RealName: strings.Join(name, " ")}) } }