godrop

package module
v0.0.0-...-48b2bb9 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: AGPL-3.0 Imports: 8 Imported by: 1

README

godrop

This is an IRC client package. It is mainly useful for creating bots.

Adding functionality

You can add functionality to clients via packages.

Packages can add to godrop.Hooks via an init() function. godrop calls each hook with every IRC protocol message. This means you can take actions based on anything that occurs on IRC.

This repository includes these packages to add functionality:

duckduckgo

This package makes the client respond to !trigger type commands on channels to query DuckDuckGo.

  • !ddg/.ddg search and show the first 4 results
  • !ddg1/.ddg1 search and show the first result
  • !duck/.duck search for an instant answers
oper

This package makes the client an IRC operator upon connect. You need to define oper-name and oper-password in your client's configuration to use it.

recordips

This package causes the client to record connecting IPs to a file. It's based on ircd-ratbox notices. The bot must be an operator to see these notices.

Documentation

Overview

Package godrop is an IRC client library.

Index

Constants

This section is empty.

Variables

View Source
var Hooks []func(*Client, irc.Message)

Hooks are functions to call for each message. Packages can take actions this way.

Functions

This section is empty.

Types

type Client

type Client struct {

	// Config holds the parsed config file data.
	//
	// TODO(horgh): This doesn't really seem to belong here.
	Config map[string]string
	// contains filtered or unexported fields
}

Client holds an IRC client connection.

func New

func New(nick, name, ident, host string, port int, tls bool) *Client

New creates a new client connection.

func (*Client) Close

func (c *Client) Close() error

Close cleans up the client. It closes the connection.

func (*Client) Connect

func (c *Client) Connect() error

Connect opens a new connection to the server.

func (*Client) GetNick

func (c *Client) GetNick() string

GetNick retrieves the client's nick.

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected checks whether the client is connected

func (*Client) IsRegistered

func (c *Client) IsRegistered() bool

IsRegistered checks whether the client is registered.

func (*Client) Join

func (c *Client) Join(name string) error

Join joins a channel.

func (*Client) Loop

func (c *Client) Loop() error

Loop enters a loop reading from the server.

We maintain the IRC connection.

Hook events will fire.

func (*Client) Message

func (c *Client) Message(target string, message string) error

Message sends a message.

If the message is too long for a single line, then it will be split over several lines.

func (*Client) Nick

func (c *Client) Nick() error

Nick sends the NICK command.

func (*Client) Oper

func (c *Client) Oper(name string, password string) error

Oper sends an OPER command

func (*Client) Pong

func (c *Client) Pong(ping irc.Message) error

Pong sends a PONG in response to the given PING message.

func (*Client) Quit

func (c *Client) Quit(message string) error

Quit sends a quit.

We track when we send this as we expect an ERROR message in response.

func (Client) ReadMessage

func (c Client) ReadMessage() (irc.Message, error)

ReadMessage reads a line from the connection and parses it as an IRC message.

func (*Client) Register

func (c *Client) Register() error

Register sends the client's registration/greeting. This consists of NICK and USER.

func (*Client) SetRegistered

func (c *Client) SetRegistered()

SetRegistered sets us as registered.

func (*Client) SetTimeoutTime

func (c *Client) SetTimeoutTime(d time.Duration)

SetTimeoutTime sets the duration we wait on reads/writes.

func (*Client) User

func (c *Client) User() error

User sends the USER command.

func (*Client) UserMode

func (c *Client) UserMode(nick string, modes string) error

UserMode sends a MODE command.

func (Client) WriteMessage

func (c Client) WriteMessage(m irc.Message) error

WriteMessage writes an IRC message to the connection.

Directories

Path Synopsis
Package duckduckgo provides the ability to query DuckDuckGo from IRC.
Package duckduckgo provides the ability to query DuckDuckGo from IRC.
Package oper makes the client become an operator.
Package oper makes the client become an operator.
Package recordips makes a client watch for user connection notices (as operator).
Package recordips makes a client watch for user connection notices (as operator).
Package twitchstreams provides a way to notify about users streaming on Twitch.
Package twitchstreams provides a way to notify about users streaming on Twitch.

Jump to

Keyboard shortcuts

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