Documentation ¶
Index ¶
- func GetMemberNick(m *discordgo.Member) string
- func Leftpad(s string, length int, ch ...rune) string
- func SnowflakeToIP(base string, snowflake string) string
- func TruncateString(length int, text string) string
- type Bridge
- func (b *Bridge) Close()
- func (b *Bridge) GetIRCChannels() map[string]string
- func (b *Bridge) GetJoinCommand() string
- func (b *Bridge) GetMappingByDiscord(channel string) *Mapping
- func (b *Bridge) GetMappingByIRC(channel string) *Mapping
- func (b *Bridge) Open() (err error)
- func (b *Bridge) SetChannelMappings(inMappings map[string]string) error
- func (b *Bridge) SetDebugMode(debug bool)
- func (b *Bridge) SetIRCListenerName(name string)
- func (b *Bridge) SetupIRCConnection(con *irc.Connection, hostname, ip string)
- type Config
- type DiscordMessage
- type DiscordUser
- type IRCManager
- func (m *IRCManager) Close()
- func (m *IRCManager) CloseConnection(i *ircConnection)
- func (m *IRCManager) DisconnectUser(userID string)
- func (m *IRCManager) HandleUser(user DiscordUser)
- func (m *IRCManager) RequestChannels(userID string) map[string]string
- func (m *IRCManager) SendMessage(channel string, msg *DiscordMessage)
- func (m *IRCManager) SetConnectionCooldown(con *ircConnection)
- type IRCMessage
- type Mapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMemberNick ¶
GetMemberNick returns the real display name for a Discord GuildMember
func SnowflakeToIP ¶
SnowflakeToIP takes a snowflake and the first half of an IP to make an IP suitable for WEBIRC
Types ¶
type Bridge ¶
type Bridge struct { Config *Config // contains filtered or unexported fields }
A Bridge represents a bridging between an IRC server and channels in a Discord server
func (*Bridge) GetIRCChannels ¶
GetIRCChannels returns a list of irc channels in no particular order.
func (*Bridge) GetJoinCommand ¶
func (*Bridge) GetMappingByDiscord ¶
GetMappingByDiscord returns a Mapping for a given Discord channel. Returns nil if a Mapping does not exist.
func (*Bridge) GetMappingByIRC ¶
GetMappingByIRC returns a Mapping for a given IRC channel. Returns nil if a Mapping does not exist.
func (*Bridge) SetChannelMappings ¶
SetChannelMappings allows you to set (or update) the hashmap containing irc to discord mappings.
Calling this function whilst the bot is running will add or remove IRC bots accordingly.
func (*Bridge) SetDebugMode ¶
SetDebugMode allows you to control debug logging.
func (*Bridge) SetIRCListenerName ¶
SetIRCListenerName changes the username of the listener bot.
func (*Bridge) SetupIRCConnection ¶
func (b *Bridge) SetupIRCConnection(con *irc.Connection, hostname, ip string)
SetupIRCConnection sets up an IRC connection with config settings like UseTLS, InsecureSkipVerify, and WebIRCPass.
type Config ¶
type Config struct {
DiscordBotToken, GuildID string
// Map from Discord to IRC
ChannelMappings map[string]string
IRCServer string
IRCServerPass string
IRCListenerName string // i.e, "DiscordBot", required to listen for messages in all cases
WebIRCPass string
NickServIdentify string // string: "[account] password"
// NoTLS constrols whether to use TLS at all when connecting to the IRC server
NoTLS bool
// InsecureSkipVerify controls whether a client verifies the
// server's certificate chain and host name.
// If InsecureSkipVerify is true, TLS accepts any certificate
// presented by the server and any host name in that certificate.
// In this mode, TLS is susceptible to man-in-the-middle attacks.
// This should be used only for testing.
InsecureSkipVerify bool
// SimpleMode, when enabled, will ensure that IRCManager not spawn
// an IRC connection for each of the online Discord users.
SimpleMode bool
// WebhookPrefix is prefixed to each webhook created by the Discord bot.
WebhookPrefix string
// WebhookLimit is the max number of webhooks to create
WebhookLimit int
Suffix string // Suffix is the suffix to append to IRC puppets
Separator string // Separator is used in IRC puppets' username, in fallback situations, between the discriminator and username.
Debug bool
}
Config to be passed to New
type DiscordMessage ¶
type DiscordMessage struct { *discordgo.Message Content string IsAction bool PmTarget string // target username, for PMs }
DiscordMessage is a chat message sent to IRC (from Discord)
type DiscordUser ¶
type DiscordUser struct { ID string // globally unique id Username string Discriminator string Nick string // still non-unique Bot bool // are they a bot? Online bool }
DiscordUser is information that IRC needs to know about a user
type IRCManager ¶
type IRCManager struct {
// contains filtered or unexported fields
}
IRCManager should only be used from one thread.
func (*IRCManager) Close ¶
func (m *IRCManager) Close()
Close closes all of an IRCManager's connections.
func (*IRCManager) CloseConnection ¶
func (m *IRCManager) CloseConnection(i *ircConnection)
CloseConnection shuts down a particular connection and its channels.
func (*IRCManager) DisconnectUser ¶
func (m *IRCManager) DisconnectUser(userID string)
DisconnectUser immediately disconnects a Discord user if it exists
func (*IRCManager) HandleUser ¶
func (m *IRCManager) HandleUser(user DiscordUser)
HandleUser deals with messages sent from a DiscordUser
func (*IRCManager) RequestChannels ¶
func (m *IRCManager) RequestChannels(userID string) map[string]string
RequestChannels finds all the Discord channels this user belongs to, and then find pairings in the global pairings list Currently just returns all participating IRC channels TODO (?)
func (*IRCManager) SendMessage ¶
func (m *IRCManager) SendMessage(channel string, msg *DiscordMessage)
SendMessage sends a broken down Discord Message to a particular IRC channel.
func (*IRCManager) SetConnectionCooldown ¶
func (m *IRCManager) SetConnectionCooldown(con *ircConnection)
SetConnectionCooldown renews/starts a timer for expiring a connection.
type IRCMessage ¶
IRCMessage is a chat message sent to Discord (from IRCListener)