Documentation ¶
Index ¶
- Variables
- 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) GetJoinCommand(mappings []Mapping) string
- func (b *Bridge) GetMappingByDiscord(channel string) (Mapping, bool)
- func (b *Bridge) GetMappingByIRC(channel string) (Mapping, bool)
- 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) []Mapping
- func (m *IRCManager) SendMessage(channel string, msg *DiscordMessage)
- func (m *IRCManager) SetConnectionCooldown(con *ircConnection)
- type IRCMessage
- type Mapping
Constants ¶
This section is empty.
Variables ¶
var DevMode = false
DevMode is a hack
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
func TruncateString ¶
TruncateString is derived from https://github.com/gohugoio/hugo/blob/a03c631c420a03f9d90699abdf9be7e4fca0ff61/tpl/strings/truncate.go#L43
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) GetJoinCommand ¶
GetJoinCommand produces a JOIN command based on the provided mappings
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 { AvatarURL string DiscordBotToken, GuildID string // Map from Discord to IRC ChannelMappings map[string]string IRCServer string Discriminator string IRCServerPass string IRCListenerName string // i.e, "DiscordBot", required to listen for messages in all cases WebIRCPass string PuppetUsername string // Username to connect to IRC with IRCIgnores []glob.Glob DiscordIgnores map[string]struct{} // Discord user IDs to not bridge DiscordAllowed map[string]struct{} // Discord user IDs to only bridge ConnectionLimit int // number of IRC connections we can spawn IRCPuppetPrejoinCommands []string IRCListenerPrejoinCommands []string // filters IRCFilteredMessages []glob.Glob DiscordFilteredMessages []glob.Glob // 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 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. // CooldownDuration is the duration in seconds for an IRC puppet to stay online before being disconnected CooldownDuration time.Duration // ShowJoinQuit determines whether or not to show JOIN, QUIT, KICK messages on Discord ShowJoinQuit bool // Maximum Nicklength for irc server MaxNickLength int Debug bool DebugPresence 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
When `user.Online == false`, we make `user.ID` the only other data present in discord.handlePresenceUpdate
func (*IRCManager) RequestChannels ¶
func (m *IRCManager) RequestChannels(userID string) []Mapping
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)