connectors

package
v0.0.0-...-69810a0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingFeedChannel is used when the feed channel is not configured.
	ErrMissingFeedChannel = errors.New("Missing feed channel")
)

Functions

This section is empty.

Types

type IRCConnector

type IRCConnector struct {
	// contains filtered or unexported fields
}

IRCConnector provides a connector service to IRC networks.

func NewIRCConnector

func NewIRCConnector(
	config *confer.Config,
	gonduitFactory *factories.GonduitFactory,
	logger *logrus.Logger,
) *IRCConnector

NewIRCConnector constructs a new instance of an IRCConnector.

func (*IRCConnector) Boot

func (c *IRCConnector) Boot() error

Boot initializes the connector.

func (*IRCConnector) Excuse

func (c *IRCConnector) Excuse(m interfaces.Message, err error)

Excuse comes up with an excuse of why something failed.

func (*IRCConnector) GetConfig

func (c *IRCConnector) GetConfig() *confer.Config

GetConfig returns an instance of the configuration store.

func (*IRCConnector) GetFeedChannel

func (c *IRCConnector) GetFeedChannel() string

GetFeedChannel returns the default channel for the bot.

func (*IRCConnector) GetGonduit

func (c *IRCConnector) GetGonduit() (*gonduit.Conn, error)

GetGonduit gets an instance of a gonduit client.

func (*IRCConnector) GetHandlers

func (c *IRCConnector) GetHandlers() []interfaces.HandlerTuple

GetHandlers returns the regular handlers loaded in this connector.

func (*IRCConnector) GetIMHandlers

func (c *IRCConnector) GetIMHandlers() []interfaces.HandlerTuple

GetIMHandlers returns the IM handlers loaded in this connector.

func (*IRCConnector) GetModules

func (c *IRCConnector) GetModules() []interfaces.Module

GetModules returns the modules used in this bot.

func (*IRCConnector) GetUsageHandler

func (c *IRCConnector) GetUsageHandler() interfaces.Handler

GetUsageHandler returns a handler to be used for when no other handlers are matched. This handler usually posts some for of help message.

func (*IRCConnector) GetUsername

func (c *IRCConnector) GetUsername(userID string) (string, error)

GetUsername returns the username of the user specified.

Since the IRC connector uses usernames as user IDs, this method is just an identity function.

func (*IRCConnector) LoadModules

func (c *IRCConnector) LoadModules(modules []interfaces.Module)

LoadModules instructs the connector to load the provided modules.

func (*IRCConnector) Post

func (c *IRCConnector) Post(
	channelName string,
	storyText string,
	icon messages.Icon,
	asUser bool,
)

Post posts a text message.

func (*IRCConnector) PostImage

func (c *IRCConnector) PostImage(
	channelName string,
	storyText string,
	imageURL string,
	icon messages.Icon,
	asUser bool,
)

PostImage posts a message with an attached image.

func (*IRCConnector) PostOnFeed

func (c *IRCConnector) PostOnFeed(storyText string) error

PostOnFeed posts a message on the bot's "feed" channel.

func (*IRCConnector) StartTyping

func (c *IRCConnector) StartTyping(channel string)

StartTyping notifies the network that the bot is typing.

The IRC protocol does not provide this feature, so include a dummy method to satisfy the interface.

type IRCMessage

type IRCMessage struct {
	// contains filtered or unexported fields
}

IRCMessage is Phabulous's representation of an IRC message. This implementation is mainly a wrapper over the message struct provided by the IRC client library.

func NewIRCMessage

func NewIRCMessage(line *client.Line, self string) *IRCMessage

NewIRCMessage constructs a new instance of an IRCMessage.

func (*IRCMessage) GetChannel

func (m *IRCMessage) GetChannel() string

GetChannel returns the channel this message was posted on.

func (*IRCMessage) GetContent

func (m *IRCMessage) GetContent() string

GetContent gets the message content.

func (*IRCMessage) GetProviderName

func (m *IRCMessage) GetProviderName() string

GetProviderName returns the name of the provider this message was delivered by. Examples: slack, irc, etc.

func (*IRCMessage) GetUserID

func (m *IRCMessage) GetUserID() string

GetUserID gets the nickname of the user who created this message.

func (*IRCMessage) HasUser

func (m *IRCMessage) HasUser() bool

HasUser returns true if the message has a user.

func (*IRCMessage) IsIM

func (m *IRCMessage) IsIM() bool

IsIM returns true if the message is a direct message sent to the bot.

func (*IRCMessage) IsSelf

func (m *IRCMessage) IsSelf() bool

IsSelf returns true if the message was posted by the bot.

type SlackConnector

type SlackConnector struct {
	// contains filtered or unexported fields
}

SlackConnector provides a connector service to Slack networks.

func NewSlackConnector

func NewSlackConnector(
	config *confer.Config,
	gonduitFactory *factories.GonduitFactory,
	logger *logrus.Logger,
) *SlackConnector

NewSlackConnector constructs an instance of a SlackConnector.

func (*SlackConnector) Boot

func (c *SlackConnector) Boot() error

Boot initializes the connector.

func (*SlackConnector) Excuse

func (c *SlackConnector) Excuse(m interfaces.Message, err error)

Excuse comes up with an excuse of why something failed.

func (*SlackConnector) GetConfig

func (c *SlackConnector) GetConfig() *confer.Config

GetConfig returns an instance of the configuration store.

func (*SlackConnector) GetFeedChannel

func (c *SlackConnector) GetFeedChannel() string

GetFeedChannel returns the default channel for the bot.

func (*SlackConnector) GetGonduit

func (c *SlackConnector) GetGonduit() (*gonduit.Conn, error)

GetGonduit gets an instance of a gonduit client.

func (*SlackConnector) GetHandlers

func (c *SlackConnector) GetHandlers() []interfaces.HandlerTuple

func (*SlackConnector) GetIMHandlers

func (c *SlackConnector) GetIMHandlers() []interfaces.HandlerTuple

func (*SlackConnector) GetModules

func (b *SlackConnector) GetModules() []interfaces.Module

GetModules returns the modules used in this bot.

func (*SlackConnector) GetSlack

func (c *SlackConnector) GetSlack() *slack.Client

func (*SlackConnector) GetUsageHandler

func (c *SlackConnector) GetUsageHandler() interfaces.Handler

GetUsageHandler returns a handler to be used for when no other handlers are matched. This handler usually posts some for of help message.

func (*SlackConnector) GetUsername

func (c *SlackConnector) GetUsername(userId string) (string, error)

func (*SlackConnector) LoadModules

func (c *SlackConnector) LoadModules(modules []interfaces.Module)

func (*SlackConnector) Post

func (c *SlackConnector) Post(
	channelName string,
	storyText string,
	icon messages.Icon,
	asUser bool,
)

Post posts a simple message to Slack. Most parameters are set to defaults.

func (*SlackConnector) PostImage

func (c *SlackConnector) PostImage(
	channelName string,
	storyText string,
	imageURL string,
	icon messages.Icon,
	asUser bool,
)

PostImage posts a simple message to Slack, with an image. Most parameters are set to defaults.

func (*SlackConnector) PostOnFeed

func (c *SlackConnector) PostOnFeed(storyText string) error

PostOnFeed posts a message to Slack on the default bot channel.

func (*SlackConnector) StartTyping

func (b *SlackConnector) StartTyping(channel string)

StartTyping notify Slack that the bot is "typing".

type SlackMessage

type SlackMessage struct {
	// contains filtered or unexported fields
}

SlackMessage is Phabulous's representation of a Slack message. This implementation is mainly a wrapper over the message struct provided by the Slack client library, along with some additional metadata.

func NewSlackMessage

func NewSlackMessage(
	ev *slack.MessageEvent,
	self string,
	imChannelIDs *map[string]bool,
) *SlackMessage

NewSlackMessage constructs a new instance of an SlackMessage.

func (*SlackMessage) GetChannel

func (m *SlackMessage) GetChannel() string

GetChannel returns the channel this message was posted on.

func (*SlackMessage) GetContent

func (m *SlackMessage) GetContent() string

GetContent gets the message content.

func (*SlackMessage) GetProviderName

func (m *SlackMessage) GetProviderName() string

GetProviderName returns the name of the provider this message was delivered by. Examples: slack, irc, etc.

func (*SlackMessage) GetUserID

func (m *SlackMessage) GetUserID() string

GetUserID gets the Slack account ID of the user who created this message.

func (*SlackMessage) HasUser

func (m *SlackMessage) HasUser() bool

HasUser returns true if the message has a user.

func (*SlackMessage) IsIM

func (m *SlackMessage) IsIM() bool

IsIM returns true if the message is a direct message sent to the bot.

func (*SlackMessage) IsSelf

func (m *SlackMessage) IsSelf() bool

IsSelf returns true if the message was posted by the bot.

Jump to

Keyboard shortcuts

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