Documentation ¶
Index ¶
Constants ¶
const Version = "1.5.2"
Version is the current version of karmabot.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶ added in v1.0.0
type Bot struct {
Config *Config
}
A Bot is an instance of karmabot.
func (*Bot) Listen ¶ added in v1.0.0
func (b *Bot) Listen()
Listen starts listening for Slack messages and calls the appropriate handlers.
func (*Bot) SendMessage ¶ added in v1.0.0
SendMessage sends a message to a Slack channel.
type ChatService ¶ added in v1.4.3
type ChatService interface { // IncomingEventsChan returns a channel of real-time events. IncomingEventsChan() chan slack.RTMEvent // NewOutgoingMessage constructs a new OutgoingMessage using the provided text and channel. NewOutgoingMessage(text string, channel string, options ...slack.RTMsgOption) *slack.OutgoingMessage // SendMessage sends the provided *OutgoingMessage. SendMessage(msg *slack.OutgoingMessage) // OpenIMChannel opens a new direct-message channel with the specified user. // It returns some status information, and the channel ID. OpenIMChannel(user string) (bool, bool, string, error) // GetUserInfo retrieves the complete user information for the specified username. GetUserInfo(user string) (*slack.User, error) }
ChatService is an abstraction around Slack, mostly designed for use in tests.
type Config ¶ added in v1.0.0
type Config struct { Slack ChatService Debug, Motivate, SelfKarma bool MaxPoints, LeaderboardLimit int Log *log.Log UI ui.Provider DB Database UserBlacklist StringList Aliases UserAliases Reactji *ReactjiConfig }
Config contains all the necessary configs for karmabot.
type Database ¶ added in v1.4.3
type Database interface { // InsertPoints persistently records that points have been given or deducted. InsertPoints(points *database.Points) error // GetUser returns information about a user, including their current number of points. GetUser(name string) (*database.User, error) // GetLeaderboard returns the top X users with the most points, in order. GetLeaderboard(limit int) (database.Leaderboard, error) // GetTotalPoints returns the total number of points transferred across all users. GetTotalPoints() (int, error) // GetThrowback returns a random karma operation on a specific user. GetThrowback(user string) (*database.Throwback, error) }
Database is an abstraction around the database, mostly designed for use in tests.
type ReactjiConfig ¶ added in v1.4.3
type ReactjiConfig struct { Enabled bool Upvote, Downvote StringList }
ReactjiConfig contains the configuration for reactji-based votes
type SlackChatService ¶ added in v1.4.3
SlackChatService is an implementation of ChatService using github.com/nlopes/slack.
func (SlackChatService) IncomingEventsChan ¶ added in v1.4.3
func (s SlackChatService) IncomingEventsChan() chan slack.RTMEvent
IncomingEventsChan returns a channel of real-time messaging events.
type StringList ¶ added in v1.3.2
type StringList map[string]struct{}
StringList is an object that accepts multiple strings and implements flag.Value
func (*StringList) Contains ¶ added in v1.4.3
func (sl *StringList) Contains(value string) bool
Contains checks if the list contains a certain item
func (*StringList) Set ¶ added in v1.3.2
func (sl *StringList) Set(value string) error
Set receives a string and appends it to the internal map
func (*StringList) String ¶ added in v1.3.2
func (sl *StringList) String() string
type UserAliases ¶ added in v1.3.2
UserAliases is a map of alias -> main username