Fetch Channel, convert IMs to string
This commit is contained in:
@@ -67,22 +67,31 @@ func main() {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("%#v\n", item)
|
||||
fmt.Printf("\t%#v\n", item.Message)
|
||||
|
||||
user, err := getUser(c, item.Message.User)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("\t%#v\n", user)
|
||||
|
||||
channel, err := getChannel(c, item.Channel)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("\t%#v\n", channel)
|
||||
title, err := getTitle(item, user, channel)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", title)
|
||||
}
|
||||
}
|
||||
|
||||
func getTitle(item *Item, user *User, channel *Channel) (string, error) {
|
||||
switch {
|
||||
case channel.IsIm:
|
||||
return fmt.Sprintf("[%s] %s", user.Name, item.Message.Text), nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown channel type: %#v", channel)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user