Fetch Channel, convert IMs to string

This commit is contained in:
Ian Gulliver
2022-10-23 23:14:24 +00:00
parent 133d958029
commit 7a44aa2f5f

View File

@@ -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)
}
}