Documentation ¶
Overview ¶
Package papaBot provides an IRC bot with focus on easy extension and customization.
Index ¶
- Constants
- type Bot
- func (bot *Bot) AddMoreInfo(transport, channel, info string) error
- func (bot *Bot) AddToIgnoreList(userId string)
- func (bot *Bot) AreSamePeople(nick1, nick2 string) bool
- func (bot *Bot) GetAuthenticatedNick(userId string) string
- func (bot *Bot) GetPageBody(URL string, customHeaders map[string]string) (error, string, []byte)
- func (bot *Bot) GetVar(name string) string
- func (bot *Bot) LoadTexts(section string, data interface{}) error
- func (bot *Bot) NextDailyTick() time.Time
- func (bot *Bot) NickIsMe(transportName, nick string) bool
- func (bot *Bot) RegisterCommand(cmd *BotCommand)
- func (bot *Bot) RegisterExtension(ext extension)
- func (bot *Bot) RegisterTransport(transport transports.Transport)
- func (bot *Bot) RemoveFromIgnoreList(userId string)
- func (bot *Bot) Run()
- func (bot *Bot) SendMassNotice(message string)
- func (bot *Bot) SendMessage(sourceEvent *events.EventMessage, message string)
- func (bot *Bot) SendNotice(sourceEvent *events.EventMessage, message string)
- func (bot *Bot) SendPrivateMessage(sourceEvent *events.EventMessage, nick, message string)
- func (bot *Bot) SetVar(name, value string)
- func (bot *Bot) UserIsAdmin(userId string) bool
- func (bot *Bot) UserIsAuthenticated(userId string) bool
- func (bot *Bot) UserIsOwner(userId string) bool
- func (bot *Bot) UserIsOwnerOrAdmin(userId string) bool
- type BotCommand
- type Configuration
Constants ¶
const ( Version = "1.0.7" Debug = false // Set to true to crash on runtime errors. BuildDate = "" )
Use: go build -ldflags "-X github.com/pawelszydlo/papa-bot/papaBot.BuildDate=`date -u +.%Y%m%d.%H%M%S`"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { // Database connection. Db *sql.DB // HTTP client. HTTPClient *http.Client // Logger. Log *logrus.Logger // Event dispatcher instance. EventDispatcher *events.EventDispatcher // Bot's configuration. Config *Configuration // Bot texts struct. Texts *botTexts // Values humanizer. Humanizer *humanize.Humanizer // Enabled transports. Transports map[string]transports.Transport // contains filtered or unexported fields }
Bot itself.
func (*Bot) AddMoreInfo ¶
AddMoreInfo will set more information to be viewed for the channel.
func (*Bot) AddToIgnoreList ¶
AddToIgnoreList will add a user to the ignore list.
func (*Bot) AreSamePeople ¶
areSamePeople checks if two nicks belong to the same person.
func (*Bot) GetAuthenticatedNick ¶
GetAuthenticatedNick will get authenticated user's nick by his full name.
func (*Bot) GetPageBody ¶
GetPageBody gets and returns a body of a page. Return format is error, final url, body.
func (*Bot) LoadTexts ¶
LoadTexts loads texts from a section of a config file into a struct, auto handling templates and lists. The name of the field in the data struct defines the name in the config file. The type of the field determines the expected config value.
func (*Bot) NextDailyTick ¶
NextDailyTick will get the time for bot's next daily tick.
func (*Bot) RegisterCommand ¶
func (bot *Bot) RegisterCommand(cmd *BotCommand)
RegisterCommand will register a new command with the bot.
func (*Bot) RegisterExtension ¶
func (bot *Bot) RegisterExtension(ext extension)
RegisterExtension will register a new extension with the bot.
func (*Bot) RegisterTransport ¶
func (bot *Bot) RegisterTransport(transport transports.Transport)
RegisterTransport will register a new transport with the bot.
func (*Bot) RemoveFromIgnoreList ¶
RemoveFromIgnoreList will remove user from the ignore list.
func (*Bot) SendMassNotice ¶
SendMassNotice sends a notice to all the channels bot is on, on all transports.
func (*Bot) SendMessage ¶
func (bot *Bot) SendMessage(sourceEvent *events.EventMessage, message string)
SendMessage sends a message to the channel.
func (*Bot) SendNotice ¶
func (bot *Bot) SendNotice(sourceEvent *events.EventMessage, message string)
SendNotice sends a notice to the channel.
func (*Bot) SendPrivateMessage ¶
func (bot *Bot) SendPrivateMessage(sourceEvent *events.EventMessage, nick, message string)
SendPrivateMessage sends a message directly to the user.
func (*Bot) UserIsAdmin ¶
userIsOwner checks if the user is an authenticated admin.
func (*Bot) UserIsAuthenticated ¶
userIsAuthenticated checks if the user is authenticated with the bot.
func (*Bot) UserIsOwner ¶
userIsOwner checks if the user is an authenticated owner.
func (*Bot) UserIsOwnerOrAdmin ¶
isOwnerOrAdmin will check whether user has privileges.
type BotCommand ¶
type BotCommand struct { // Names of the command (main and aliases). CommandNames []string // Does this command require private query? Private bool // This command can only be run by the owner? Owner bool // This command can only be run by an admin? Admin bool // Help string showing possible parameters. HelpParams string // Help string with the description. HelpDescription string // Function to be executed. CommandFunc func(bot *Bot, sourceEvent *events.EventMessage, params []string) }
Bot's commands.
type Configuration ¶
type Configuration struct { Name string Language string ChatLogging bool CommandsPer5 int UrlAnnounceIntervalMinutes time.Duration UrlAnnounceIntervalLines int PageBodyMaxSize uint HttpDefaultUserAgent string DailyTickHour int DailyTickMinute int LogLevel logrus.Level }
Bot's configuration. It will be loaded from the provided file on New(), overwriting any defaults.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Example usage of papaBot.
|
Example usage of papaBot. |
Extensions for papaBot.
|
Extensions for papaBot. |
Helpful utility functions.
|
Helpful utility functions. |