-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add reddit grabber function & techgore command #11
base: master
Are you sure you want to change the base?
Changes from 4 commits
4e513e5
dd7056f
d84dbad
3a52c86
62344c4
cbfffd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,6 +224,10 @@ func streams(s *discordgo.Session, m *discordgo.Message, parv []string) error { | |
} | ||
|
||
func derpi(s *discordgo.Session, m *discordgo.Message, parv []string) error { | ||
if m.ChannelID != "292755043684450304" { | ||
s.ChannelMessageSend(m.ChannelID, "Please use this command only in #diabeetus") | ||
return nil | ||
} | ||
searchResults, err := derpiSearch.SearchDerpi(m.Content[7:len(m.Content)]) | ||
if err != nil { | ||
s.ChannelMessageSend(m.ChannelID, "An error occured.") | ||
|
@@ -236,3 +240,16 @@ func derpi(s *discordgo.Session, m *discordgo.Message, parv []string) error { | |
s.ChannelMessageSend(m.ChannelID, "http:"+searchResults.Search[randomRange(0, len(searchResults.Search))].Image) | ||
return nil | ||
} | ||
|
||
func techgore(s *discordgo.Session, m *discordgo.Message, parv []string) error { | ||
if m.ChannelID != "193740418633039872" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make this a configuration setting using an environment variable. |
||
s.ChannelMessageSend(m.ChannelID, "Please use this command only in #nerdery") | ||
return nil // only works in #nerdery | ||
} | ||
results, err := redditSearch("techsupportgore") | ||
if err != nil { | ||
return err | ||
} | ||
s.ChannelMessageSend(m.ChannelID, results[randomRange(0, len(results))].URL) | ||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import "github.com/jzelinskie/geddit" | ||
|
||
func redditSearch(subreddit string) ([]*geddit.Submission, error) { | ||
listOptions := geddit.ListingOptions{ | ||
Limit: 50, | ||
} | ||
reddit := geddit.NewSession("discordbot") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/reddit/reddit/wiki/API#rules Prefer something like const (
appid = "github.com/PonyvilleFM/aura/cmd/aerial"
version = "0.1"
)
userAgent := fmt.Sprintf(
"%s on %s %s:%s:%s (by /u/shadowh511)",
runtime.Version(), runtime.GOOS, runtime.GOARCH,
appid, version,
) |
||
results, err := reddit.SubredditSubmissions(subreddit, geddit.NewSubmissions, listOptions) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return results, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this a configuration setting using an environment variable.