Documentation ¶
Overview ¶
Package botfaces defines interfaces graw uses to connect bots to event streams on Reddit. There is no need to import this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommentHandler ¶
type CommentHandler interface { // Comment is called when a comment is made in a monitored subreddit // that the bot has not seen yet. [Called as goroutine.] Comment(post *reddit.Comment) error }
CommentHandler defines methods for bots that handle new comments in subreddits they monitor.
type CommentReplyHandler ¶
type CommentReplyHandler interface { // CommentReply is called when the bot receives a reply to one of its // comments in it its inbox. [Called as goroutine.] // // The reply is in the form of a message because that is how it arrives // in the Reddit inbox, but it is originally a comment and replying to // this with the Reddit package will still generate a comment. CommentReply(reply *reddit.Message) error }
CommentReplyHandler defines methods for bots that handle new comments made in reply to their own.
type Loader ¶
type Loader interface { // SetUp is the first method ever called on the bot, and it will be // allowed to finish before other methods are called. Bots should // load resources here. If an error is returned, the engine will not // start, and the error will propagate up. SetUp() error }
Loader defines methods for bots that use external resources or need to do initialization.
type MentionHandler ¶
type MentionHandler interface { // Mention is called when the bot receives a username mention in its // inbox. [Called as goroutine.] // // The reply is in the form of a message because that is how it arrives // in the Reddit inbox, but it is originally a comment and replying to // this with the Reddit package will still generate a comment. Mention(mention *reddit.Message) error }
MentionHandler defines methods for bots that handle username mentions. These will only appear in the inbox if
- The bot's account preferences are set to monitor username mentions.
- The event type is not shadowed.
Reddit will shadow a username mention under two other event types. If the bot's username is mentioned in a comment posted on its submission, the inbox item will be a post reply, not a mention. If the bot's username is mentioned in a comment posted in reply to one of the bot's comments, the inbox item will be a comment reply, not a mention. In both cases, this handler is unused.
type MessageHandler ¶
type MessageHandler interface { // Message is called when the bot receives a new private message to its // account. [Called as goroutine.] Message(msg *reddit.Message) error }
MessageHandler defines methods for bots that handle new private messages to their inbox.
type PostHandler ¶
type PostHandler interface { // Post is called when a post is made in a monitored subreddit that the // bot has not seen yet. [Called as goroutine.] Post(post *reddit.Post) error }
PostHandler defines methods for bots that handle new posts in subreddits they monitor.
type PostReplyHandler ¶
type PostReplyHandler interface { // Reply is called when the bot receives a reply to one of its // submissions in its inbox. [Called as goroutine.] // // The reply is in the form of a message because that is how it arrives // in the Reddit inbox, but it is originally a comment and replying to // this with the Reddit package will still generate a comment. PostReply(reply *reddit.Message) error }
PostReplyHandler defines methods for bots that handle new top-level comments on their submissions.
type Tearer ¶
type Tearer interface { // TearDown is the last method ever called on the bot, and all other // method calls will finish before this method is called. Bots should // unload resources here. TearDown() }
Tearer defines methods for bots that need to tear things down after their run is finished.
type UserHandler ¶
type UserHandler interface { // UserPost is called when a monitored user makes a post in a subreddit // the bot can view. [Called as goroutine.] UserPost(post *reddit.Post) error // UserComment is called when the monitored user makes a comment in a // subreddit the bot can view. [Called as goroutine.] UserComment(comment *reddit.Comment) error }
UserHandler defines methods for bots that handle activity by monitored users.