Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bookmark command which sends tagged info about current track #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/aerial/aerial.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func main() {
a.cs.AddCmd("stats", "shows radio station statistics for Ponyville FM", bot.NoPermissions, stats)
a.cs.AddCmd("dj", "shows which DJ is up next on Ponyville FM", bot.NoPermissions, stats)
a.cs.AddCmd("schedule", "shows the future radio schedule for Ponyville FM", bot.NoPermissions, schedule)
a.cs.AddCmd("bookmark", "sends info about the current track on Main stream with [**BOOKMARK**] tag, so you can easily find it", bot.NoPermissions, bookmark)
a.cs.AddCmd("bm", "short for `bookmark`", bot.NoPermissions, bookmark)
a.cs.AddCmd("printerfact", "shows useful facts about printers", bot.NoPermissions, printerFact)
a.cs.AddCmd("hipster", "hip me up fam", bot.NoPermissions, hipster)
a.cs.AddCmd("source", "source code information", bot.NoPermissions, source.Source)
Expand Down
25 changes: 25 additions & 0 deletions cmd/aerial/pvfm.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ func schedule(s *discordgo.Session, m *discordgo.Message, parv []string) error {
return nil
}

func bookmark(s *discordgo.Session, m *discordgo.Message, parv []string) error {

i, err := pvfm.GetStats()
if err != nil {
log.Printf("Error getting the station info: %v, falling back to plan b", err)
return doStatsFromStation(s, m, parv)
}

st, err := station.GetStats()
if err != nil {
return err
}

authorChannel, err := s.UserChannelCreate(m.Author.ID)
if err != nil {
return err
}

s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<@%s> bookmark now is in your DM!", m.Author.ID))
s.ChannelMessageSend(authorChannel.ID, fmt.Sprintf("[**BOOKMARK**] *use a channel search to find all your bookmarks*\n"+i.Main.Nowplaying))

return nil

}

func doStationRequest(s *discordgo.Session, m *discordgo.Message, parv []string) error {
stats, err := station.GetStats()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions internal/bot/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ func (cs *CommandSet) help(s *discordgo.Session, m *discordgo.Message, parv []st
return err
}

s.ChannelMessageSend(authorChannel.ID, result)

s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("<@%s> check direct messages, help is there!", m.Author.ID))
s.ChannelMessageSend(authorChannel.ID, result)

default:
return ErrParvCountMismatch
Expand Down