bot

package module
v0.0.0-...-4d6a1d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2016 License: MIT Imports: 15 Imported by: 52

README

Cara

An IRC Bot written in Go - All credit to 0x263b, Cara is just a clowny Porygon2 with poorly implemented changes for a bunch of idiots

Install
# Dependencies
go get -u github.com/thoj/go-ircevent github.com/steveyen/gkvlite github.com/PuerkitoBio/goquery github.com/dustin/go-humanize github.com/kennygrant/sanitize gopkg.in/xmlpath.v2 github.com/kurrik/oauth1a github.com/kurrik/twittergo

# Cara
go get github.com/Seventy-Two/Cara
APIs that require keys

Functions

8Ball

Gives and 8ball style answer to a question

Cara, question?

Cara, Am I going to score with this one girl I just finished talking to?
My sources say no
Bing

Gets the first result from Bing for search query

.g/.google/.b/.bing search query

.bing Richard Stallman
Bing | Richard Stallman's Personal Page | http://stallman.org/

Gets the first result from Bing for search query

.g/.google/.b/.bing[0-9] search query

Gets the first result from Bing image search for search query

.img search query

.img Richard Stallman
Bing | Richard Stallman → image/jpeg 257 kB | http://www.straferight.com/photopost/data/500/richard-stallman.jpg

Gets the 0-9th result from Bing image search for search query

.img[0-9] search query

Carapic

Returns a randomly selected image of Cara Delevingne from Big Dave's personal collection.

.carapic

Dictionary

Returns the word of the day from Wordnik

.word/.wotd

Returns the Wordnik dictionary results (up to 3) for the given query

.dict search query

Divegrass

Returns the upcoming games for the given number of days

.f n1-9

Returns the scores of the games from the past number of days

.f p1-9

Simulates behaviour of n1

.f

DotA2

Returns information on the current games being played. For tier 3 (Premium) games, games with more than 200 viewers are returned. For tier 2 (Professional) games, games with more than 1000 viewers are returned.

.d2/dota

Returns heroes picked, along with the above

.d2h

Returns scores along with the game data

.d2s

Returns all information

.d2hs

Last.fm

Associates your current irc nick with user. Other lastfm functions will default to this nick if no user is provided.

.set lastfm user

<joebloggs> .set lastfm JosefBloggs
<Cara> joebloggs: last.fm user updated to: JosefBloggs

Weekly stats for user

.charts user

.charts Cbbleh
Last.fm | Top 5 Weekly artists for Cbbleh | Slayer (26), Iced Earth (25), Jean-Féry Rebel (23), Morbid Saint (15), Judas Priest (14)

Returns the currently playing/last scrobbled track for user and top artist tags

.np user

.np Cbbleh
Last.fm | cbbleh is playing: "Super X-9" by Daikaiju from Daikaiju | Surf, surf rock, instrumental, instrumental surf rock

Returns the currently playing track for the users in the channel that have set a lastfm account

.wp

.wp 

Sets a nickname for the wp command so that you are not highlighted during wp

.set nick user

Omdb

Returns tags, imdb + rt ratings, and short descriptions of the given query

.m/.movie search query

Random

Randomly picks an option from an array separated by |

.rand one | two | three

.r do work | don't do work
don't do work
Roll

Rolls the given number of d10s

.r/.roll 0-99

Rolls the given number of dice, of the given number of sides

.r/.roll 0-99d0-99

Stocks

Returns the current ask price, and the current change in % and USD from the NYSE of the given query. Query format must be a NYSE Symbol.

.s/.stocks Query

TVMaze

Info for tv show with episode airtime if available -tv tv show

-tv Better call saul
TVmaze | Better Call Saul | Airtime: Monday 22:00 on AMC | Status: Running | Next Ep: S2E6 at 22:00 2016-03-21

-tv Mr Robot
TVmaze | Mr. Robot | Airtime: Wednesday 22:00 on USA Network | Status: Running
Twitter

Latest tweet for user .tw/.twitter user

.twitter Guardian
Twitter | The Guardian (@guardian) | Aston Villa target Rémi Garde after sacking Tim Sherwood https://t.co/cqcgUpiEOJ via @guardian_sport | 31 seconds ago
Urban Dictionary

Gets the first definition of query at UrbanDictionary

.u/.ur/.urban query

.urban 4chan
Urban Dictionary | 4chan | http://mnn.im/upucr | you have just entered the very heart, soul, and life force of the internet. this is a place beyond sanity, wild and untamed. there is nothing new here. "new" content on 4chan is not found; it is created from old material. every interesting, offensive, shoc…

Gets the nth definition for query (only works for definitions 1-7)

.u/.ur/.urban n query

.urban 3 4chan
UrbanDictionary | 4chan | 4chan.org is the absolute hell hole of the internet, but still amusing. Entering this website requires you leave your humanity behind before entering. WARNING: You will see things on /b/ that you wish you had never seen in your life.
URL Parser

Returns the title of a page and the host for html URLs. Returns the type, size, and (sometimes) filename of a file URL.

https://news.ycombinator.com/
Title | Hacker News | news.ycombinator.com

https://41.media.tumblr.com/bca28cbcbba3718cd67fd20062df19b9/tumblr_nl8gekhnLU1tdhimpo1_1280.png
File | image/png 272kB | 41.media.tumblr.com
User Profiles

Returns the set variables for a user

.whois qb
qb | Twitter: @abnormcore | URL: https://dribbble.com/qb

Variables are set using .set url url or .set twitter handle

.set twitter someone
twitter updated to: someone

.set url http://www.something.com/
url updated to: http://www.something.com/
Weather

Yahoo Weather for location .w/.we/.weather location

.weather Washington, DC
Weather | Washington | Cloudy 15°C. Wind chill: 15°C. Humidity: 72%

Yahoo Weather Forecast for location .fo/.forecast location

.forecast Washington, DC
Forecast | Washington | Sun: Clouds Early/Clearing Late 16°C/10°C | Mon: Mostly Sunny 19°C/8°C | Tue: Mostly Sunny 23°C/11°C | Wed: Partly Cloudy 24°C/11°C

Associates your current irc nick with location. Other weather functions will default to this location if none is provided.

.set location location

<joebloggs> .set location Washington, DC
<Cara> joebloggs: location updated to: Washington, DC
WolframAlpha

Finds the answer of question using WolfarmAlpha

.wa question

.wa time in Bosnia
Wolfram | current time in Bosnia and Herzegovina >>> 12:55:38 pm CEST | Tuesday, October 6, 2015
Youtube

Gets the first result from Youtube for search query

.yt/.youtube search query

.yt Richard Stallman interject
YouTube | I'd just like to interject... | 3m1s | https://youtu.be/QlD9UBTcSW4

Admin functions

These functions are limited to bot admins and can only be used in a private message.

Ignore a user

.set ignore nick

.set ignore Cbbleh
<Cara> I never liked him anyway

Unignore a user

.set unignore nick

.set unignore Cbbleh
<Cara> Sorry about that

Toggles the URL parser for the channel

.set urls on/off channel

.set urls on #lobby
<Cara> Now reacting to URLs in #lobby

Toggles the file URL parser for the channel

.set files on/off channel

.set files on #lobby
<Cara> No longer displaying file info in #lobby	

Joins a channel and adds it to auto join

.join channel

.join #foobar
* Cara has joined #foobar

Parts a channel and removes it from auto join

.part channel

.part #foobar
* Cara has left the channel

Documentation

Overview

Package bot provides a simple to use IRC bot

Index

Constants

This section is empty.

Variables

View Source
var (
	Conn         *irc.Connection
	Config       *Configure
	ChannelNicks = make(map[string][]string)
)

Functions

func ConfigureEvents

func ConfigureEvents()

func DeleteUserKey

func DeleteUserKey(nick string, key string)

func GetChannelKey

func GetChannelKey(channel string, key string) bool

func GetChannelKeyStr

func GetChannelKeyStr(channel string, key string) string

func GetNames

func GetNames(channel string) []string

func GetUserKey

func GetUserKey(nick string, key string) string

func IsAdmin

func IsAdmin(senderNick string) bool

func IsIgnored

func IsIgnored(senderNick string) bool

func IsPrivateMsg

func IsPrivateMsg(channel, currentNick string) bool

func Out

func Out(text string)

func RegisterCommand

func RegisterCommand(command string, cmdFunc activeCmdFunc)

func RegisterMultiCommand

func RegisterMultiCommand(command string, cmdFunc activeMultiCmdFunc)

func RegisterPassiveCommand

func RegisterPassiveCommand(command string, cmdFunc func(cmd *PassiveCmd) (string, error))

func Run

func Run(c *Configure)

Run reads the Config, connect to the specified IRC server and starts the bot. The bot will automatically join all the channels specified in the Configuration

func SetChannelKey

func SetChannelKey(channel string, key string, value bool)

func SetChannelKeyStr

func SetChannelKeyStr(channel string, key string, value string)

func SetUserKey

func SetUserKey(nick string, key string, value string)

Types

type API

type API struct {
	Lastfm                string
	Giphy                 string
	TranslateClient       string
	TranslateSecret       string
	TwitterConsumerKey    string
	TwitterConsumerSecret string
	Weather               string
	Wolfram               string
	Youtube               string
	Geocode               string
	FootballData          string
	Dota                  string
	Wordnik               string
}

type Cmd

type Cmd struct {
	Raw     string   // Raw is full string passed to the command
	Channel string   // Channel where the command was called
	Nick    string   // User who sent the message
	Message string   // Full string without the prefix
	Command string   // Command is the first argument passed to the bot
	FullArg string   // Full argument as a single string
	Args    []string // Arguments as array
}

Cmd holds the parsed user's input for easier handling of commands

type Configure

type Configure struct {
	Server        string // IRC server:port. Ex: irc.rizon.net:6697
	Channel       string // Initial channel to connect. Ex: "#channel"
	User          string // The IRC username the bot will use
	Nick          string // The nick the bot will use
	Nickserv      string // Nickserv password
	Password      string // Server password
	Modes         string // User modes. Ex: GRp
	UseTLS        bool   // Should connect using TLS? (yes)
	TLSServerName string // Must supply if UseTLS is true
	Debug         bool   // This will log all IRC communication to standad output
	Prefix        string // Prefix used to identify a command. !hello whould be identified as a command
	AltPrefix     string
	Owner         string // Owner of the bot. Used for admin-only commands
	API
}

Configure must contain the necessary data to connect to an IRC server

type Directory

type Directory struct {
	Lean     string
	Quotelog string
}

type PassiveCmd

type PassiveCmd struct {
	Raw     string // Raw message sent to the channel
	Channel string // Channel which the message was sent to
	Nick    string // Nick of the user which sent the message
}

PassiveCmd holds the information which will be passed to passive commands when receiving a message on the channel

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL