2016-08-14 21:48:51 +02:00
|
|
|
package birc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
2016-10-29 18:59:12 +02:00
|
|
|
"fmt"
|
2018-05-11 23:02:43 +02:00
|
|
|
"hash/crc32"
|
2020-10-20 00:33:15 +02:00
|
|
|
"io/ioutil"
|
2017-10-20 22:22:13 +02:00
|
|
|
"net"
|
2016-08-14 21:48:51 +02:00
|
|
|
"sort"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"time"
|
2018-06-09 12:47:40 +02:00
|
|
|
|
|
|
|
"github.com/42wim/matterbridge/bridge"
|
|
|
|
"github.com/42wim/matterbridge/bridge/config"
|
|
|
|
"github.com/42wim/matterbridge/bridge/helper"
|
|
|
|
"github.com/lrstanley/girc"
|
2020-05-23 21:46:15 +02:00
|
|
|
stripmd "github.com/writeas/go-strip-markdown"
|
2018-11-14 22:43:52 +01:00
|
|
|
|
|
|
|
// We need to import the 'data' package as an implicit dependency.
|
|
|
|
// See: https://godoc.org/github.com/paulrosania/go-charset/charset
|
|
|
|
_ "github.com/paulrosania/go-charset/data"
|
2016-08-14 21:48:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Birc struct {
|
2018-03-04 23:52:14 +01:00
|
|
|
i *girc.Client
|
|
|
|
Nick string
|
|
|
|
names map[string][]string
|
2018-11-23 00:26:50 +01:00
|
|
|
connected chan error
|
2018-03-04 23:52:14 +01:00
|
|
|
Local chan config.Message // local queue for flood control
|
2018-11-23 00:26:50 +01:00
|
|
|
FirstConnection, authDone bool
|
2018-03-04 23:52:14 +01:00
|
|
|
MessageDelay, MessageQueue, MessageLength int
|
2020-11-22 22:44:15 +01:00
|
|
|
channels map[string]bool
|
2018-03-04 23:52:14 +01:00
|
|
|
|
|
|
|
*bridge.Config
|
2016-08-14 21:48:51 +02:00
|
|
|
}
|
|
|
|
|
2018-03-04 23:52:14 +01:00
|
|
|
func New(cfg *bridge.Config) bridge.Bridger {
|
2016-08-14 21:48:51 +02:00
|
|
|
b := &Birc{}
|
2018-03-04 23:52:14 +01:00
|
|
|
b.Config = cfg
|
|
|
|
b.Nick = b.GetString("Nick")
|
2016-08-14 21:48:51 +02:00
|
|
|
b.names = make(map[string][]string)
|
2018-11-23 00:26:50 +01:00
|
|
|
b.connected = make(chan error)
|
2020-11-22 22:44:15 +01:00
|
|
|
b.channels = make(map[string]bool)
|
|
|
|
|
2018-03-04 23:52:14 +01:00
|
|
|
if b.GetInt("MessageDelay") == 0 {
|
|
|
|
b.MessageDelay = 1300
|
2018-03-06 20:51:02 +01:00
|
|
|
} else {
|
|
|
|
b.MessageDelay = b.GetInt("MessageDelay")
|
2016-11-01 22:52:28 +01:00
|
|
|
}
|
2018-03-04 23:52:14 +01:00
|
|
|
if b.GetInt("MessageQueue") == 0 {
|
|
|
|
b.MessageQueue = 30
|
2018-03-06 20:51:02 +01:00
|
|
|
} else {
|
|
|
|
b.MessageQueue = b.GetInt("MessageQueue")
|
2016-11-01 22:52:28 +01:00
|
|
|
}
|
2018-03-04 23:52:14 +01:00
|
|
|
if b.GetInt("MessageLength") == 0 {
|
|
|
|
b.MessageLength = 400
|
2018-03-06 20:51:02 +01:00
|
|
|
} else {
|
|
|
|
b.MessageLength = b.GetInt("MessageLength")
|
2017-05-29 21:54:34 +02:00
|
|
|
}
|
2017-06-18 00:13:10 +02:00
|
|
|
b.FirstConnection = true
|
2016-08-14 21:48:51 +02:00
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Birc) Command(msg *config.Message) string {
|
2018-11-08 00:46:34 +01:00
|
|
|
if msg.Text == "!users" {
|
2017-10-20 22:22:13 +02:00
|
|
|
b.i.Handlers.Add(girc.RPL_NAMREPLY, b.storeNames)
|
|
|
|
b.i.Handlers.Add(girc.RPL_ENDOFNAMES, b.endNames)
|
2018-11-28 10:58:56 +01:00
|
|
|
b.i.Cmd.SendRaw("NAMES " + msg.Channel) //nolint:errcheck
|
2016-08-14 21:48:51 +02:00
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2016-08-15 23:16:07 +02:00
|
|
|
func (b *Birc) Connect() error {
|
2018-03-06 20:41:34 +01:00
|
|
|
b.Local = make(chan config.Message, b.MessageQueue+10)
|
2018-03-04 23:52:14 +01:00
|
|
|
b.Log.Infof("Connecting %s", b.GetString("Server"))
|
2018-11-28 10:58:56 +01:00
|
|
|
|
|
|
|
i, err := b.getClient()
|
2016-08-15 23:16:07 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-10-20 22:22:13 +02:00
|
|
|
|
2018-03-04 23:52:14 +01:00
|
|
|
if b.GetBool("UseSASL") {
|
2018-11-07 20:36:50 +01:00
|
|
|
i.Config.SASL = &girc.SASLPlain{
|
|
|
|
User: b.GetString("NickServNick"),
|
|
|
|
Pass: b.GetString("NickServPassword"),
|
|
|
|
}
|
2017-10-20 22:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
i.Handlers.Add(girc.RPL_WELCOME, b.handleNewConnection)
|
|
|
|
i.Handlers.Add(girc.RPL_ENDOFMOTD, b.handleOtherAuth)
|
2019-01-24 21:58:27 +01:00
|
|
|
i.Handlers.Add(girc.ERR_NOMOTD, b.handleOtherAuth)
|
2018-02-22 18:56:21 +01:00
|
|
|
i.Handlers.Add(girc.ALL_EVENTS, b.handleOther)
|
2019-01-24 21:51:52 +01:00
|
|
|
b.i = i
|
2018-11-23 00:26:50 +01:00
|
|
|
|
2018-11-28 10:58:56 +01:00
|
|
|
go b.doConnect()
|
|
|
|
|
2018-11-23 00:26:50 +01:00
|
|
|
err = <-b.connected
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("connection failed %s", err)
|
2016-10-29 18:59:12 +02:00
|
|
|
}
|
2018-11-23 00:26:50 +01:00
|
|
|
b.Log.Info("Connection succeeded")
|
|
|
|
b.FirstConnection = false
|
2018-03-04 23:52:14 +01:00
|
|
|
if b.GetInt("DebugLevel") == 0 {
|
2018-02-22 18:56:21 +01:00
|
|
|
i.Handlers.Clear(girc.ALL_EVENTS)
|
|
|
|
}
|
2016-11-01 22:52:28 +01:00
|
|
|
go b.doSend()
|
2016-08-15 23:16:07 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-02-14 21:12:02 +01:00
|
|
|
func (b *Birc) Disconnect() error {
|
2018-03-04 23:52:14 +01:00
|
|
|
b.i.Close()
|
2017-02-14 21:12:02 +01:00
|
|
|
close(b.Local)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-08-12 14:51:41 +02:00
|
|
|
func (b *Birc) JoinChannel(channel config.ChannelInfo) error {
|
2020-11-22 22:44:15 +01:00
|
|
|
b.channels[channel.Name] = true
|
2018-11-23 00:26:50 +01:00
|
|
|
// need to check if we have nickserv auth done before joining channels
|
|
|
|
for {
|
|
|
|
if b.authDone {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
}
|
2017-08-12 14:51:41 +02:00
|
|
|
if channel.Options.Key != "" {
|
2018-02-27 00:33:21 +01:00
|
|
|
b.Log.Debugf("using key %s for channel %s", channel.Options.Key, channel.Name)
|
2017-10-20 22:22:13 +02:00
|
|
|
b.i.Cmd.JoinKey(channel.Name, channel.Options.Key)
|
2017-08-12 14:51:41 +02:00
|
|
|
} else {
|
2017-10-20 22:22:13 +02:00
|
|
|
b.i.Cmd.Join(channel.Name)
|
2017-08-12 14:51:41 +02:00
|
|
|
}
|
2016-09-18 19:21:15 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-08-27 22:59:37 +02:00
|
|
|
func (b *Birc) Send(msg config.Message) (string, error) {
|
2017-09-11 22:45:15 +02:00
|
|
|
// ignore delete messages
|
2018-11-15 20:43:43 +01:00
|
|
|
if msg.Event == config.EventMsgDelete {
|
2017-09-11 22:45:15 +02:00
|
|
|
return "", nil
|
|
|
|
}
|
2018-02-24 23:56:35 +01:00
|
|
|
|
2018-02-28 22:23:29 +01:00
|
|
|
b.Log.Debugf("=> Receiving %#v", msg)
|
2018-02-24 23:56:35 +01:00
|
|
|
|
2018-03-05 22:50:38 +01:00
|
|
|
// we can be in between reconnects #385
|
|
|
|
if !b.i.IsConnected() {
|
|
|
|
b.Log.Error("Not connected to server, dropping message")
|
2019-04-06 22:34:41 +02:00
|
|
|
return "", nil
|
2018-03-05 22:50:38 +01:00
|
|
|
}
|
|
|
|
|
2018-02-24 23:56:35 +01:00
|
|
|
// Execute a command
|
2016-08-14 21:48:51 +02:00
|
|
|
if strings.HasPrefix(msg.Text, "!") {
|
|
|
|
b.Command(&msg)
|
|
|
|
}
|
2017-08-30 20:59:54 +02:00
|
|
|
|
2018-02-24 23:56:35 +01:00
|
|
|
// convert to specified charset
|
2018-11-28 10:58:56 +01:00
|
|
|
if err := b.handleCharset(&msg); err != nil {
|
|
|
|
return "", err
|
2017-08-30 20:59:54 +02:00
|
|
|
}
|
|
|
|
|
2018-11-28 10:58:56 +01:00
|
|
|
// handle files, return if we're done here
|
|
|
|
if ok := b.handleFiles(&msg); ok {
|
|
|
|
return "", nil
|
2017-11-24 22:36:19 +01:00
|
|
|
}
|
|
|
|
|
2018-11-14 22:43:52 +01:00
|
|
|
var msgLines []string
|
2020-05-23 21:46:15 +02:00
|
|
|
if b.GetBool("StripMarkdown") {
|
|
|
|
msg.Text = stripmd.Strip(msg.Text)
|
|
|
|
}
|
|
|
|
|
2018-03-04 23:52:14 +01:00
|
|
|
if b.GetBool("MessageSplit") {
|
2021-05-27 21:45:23 +02:00
|
|
|
msgLines = helper.GetSubLines(msg.Text, b.MessageLength, b.GetString("MessageClipped"))
|
2018-11-14 22:43:52 +01:00
|
|
|
} else {
|
2021-05-27 21:45:23 +02:00
|
|
|
msgLines = helper.GetSubLines(msg.Text, 0, b.GetString("MessageClipped"))
|
2017-11-24 23:27:13 +01:00
|
|
|
}
|
2018-11-14 22:43:52 +01:00
|
|
|
for i := range msgLines {
|
|
|
|
if len(b.Local) >= b.MessageQueue {
|
2018-02-27 00:33:21 +01:00
|
|
|
b.Log.Debugf("flooding, dropping message (queue at %d)", len(b.Local))
|
2018-11-14 22:43:52 +01:00
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2020-02-09 22:10:18 +01:00
|
|
|
msg.Text = msgLines[i]
|
|
|
|
b.Local <- msg
|
2016-09-29 21:21:24 +02:00
|
|
|
}
|
2017-08-27 22:59:37 +02:00
|
|
|
return "", nil
|
2016-08-14 21:48:51 +02:00
|
|
|
}
|
|
|
|
|
2018-11-28 10:58:56 +01:00
|
|
|
func (b *Birc) doConnect() {
|
|
|
|
for {
|
|
|
|
if err := b.i.Connect(); err != nil {
|
|
|
|
b.Log.Errorf("disconnect: error: %s", err)
|
|
|
|
if b.FirstConnection {
|
|
|
|
b.connected <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
b.Log.Info("disconnect: client requested quit")
|
|
|
|
}
|
|
|
|
b.Log.Info("reconnecting in 30 seconds...")
|
|
|
|
time.Sleep(30 * time.Second)
|
|
|
|
b.i.Handlers.Clear(girc.RPL_WELCOME)
|
|
|
|
b.i.Handlers.Add(girc.RPL_WELCOME, func(client *girc.Client, event girc.Event) {
|
|
|
|
b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EventRejoinChannels}
|
|
|
|
// set our correct nick on reconnect if necessary
|
|
|
|
b.Nick = event.Source.Name
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-30 18:21:32 +01:00
|
|
|
// Sanitize nicks for RELAYMSG: replace IRC characters with special meanings with "-"
|
|
|
|
func sanitizeNick(nick string) string {
|
|
|
|
sanitize := func(r rune) rune {
|
|
|
|
if strings.ContainsRune("!+%@&#$:'\"?*,. ", r) {
|
|
|
|
return '-'
|
|
|
|
}
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
return strings.Map(sanitize, nick)
|
|
|
|
}
|
|
|
|
|
2016-11-01 22:52:28 +01:00
|
|
|
func (b *Birc) doSend() {
|
2018-03-04 23:52:14 +01:00
|
|
|
rate := time.Millisecond * time.Duration(b.MessageDelay)
|
2017-07-14 00:35:01 +02:00
|
|
|
throttle := time.NewTicker(rate)
|
2016-11-01 22:52:28 +01:00
|
|
|
for msg := range b.Local {
|
2017-07-14 00:35:01 +02:00
|
|
|
<-throttle.C
|
2018-05-11 23:02:43 +02:00
|
|
|
username := msg.Username
|
2020-12-30 18:21:32 +01:00
|
|
|
// Optional support for the proposed RELAYMSG extension, described at
|
|
|
|
// https://github.com/jlu5/ircv3-specifications/blob/master/extensions/relaymsg.md
|
|
|
|
// nolint:nestif
|
|
|
|
if (b.i.HasCapability("overdrivenetworks.com/relaymsg") || b.i.HasCapability("draft/relaymsg")) &&
|
|
|
|
b.GetBool("UseRelayMsg") {
|
|
|
|
username = sanitizeNick(username)
|
|
|
|
text := msg.Text
|
|
|
|
|
|
|
|
// Work around girc chomping leading commas on single word messages?
|
|
|
|
if strings.HasPrefix(text, ":") && !strings.ContainsRune(text, ' ') {
|
|
|
|
text = ":" + text
|
|
|
|
}
|
2020-11-22 22:21:02 +01:00
|
|
|
|
2020-12-30 18:21:32 +01:00
|
|
|
if msg.Event == config.EventUserAction {
|
|
|
|
b.i.Cmd.SendRawf("RELAYMSG %s %s :\x01ACTION %s\x01", msg.Channel, username, text) //nolint:errcheck
|
|
|
|
} else {
|
|
|
|
b.Log.Debugf("Sending RELAYMSG to channel %s: nick=%s", msg.Channel, username)
|
|
|
|
b.i.Cmd.SendRawf("RELAYMSG %s %s :%s", msg.Channel, username, text) //nolint:errcheck
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if b.GetBool("Colornicks") {
|
|
|
|
checksum := crc32.ChecksumIEEE([]byte(msg.Username))
|
|
|
|
colorCode := checksum%14 + 2 // quick fix - prevent white or black color codes
|
|
|
|
username = fmt.Sprintf("\x03%02d%s\x0F", colorCode, msg.Username)
|
|
|
|
}
|
|
|
|
switch msg.Event {
|
|
|
|
case config.EventUserAction:
|
|
|
|
b.i.Cmd.Action(msg.Channel, username+msg.Text)
|
|
|
|
case config.EventNoticeIRC:
|
|
|
|
b.Log.Debugf("Sending notice to channel %s", msg.Channel)
|
|
|
|
b.i.Cmd.Notice(msg.Channel, username+msg.Text)
|
|
|
|
default:
|
|
|
|
b.Log.Debugf("Sending to channel %s", msg.Channel)
|
|
|
|
b.i.Cmd.Message(msg.Channel, username+msg.Text)
|
|
|
|
}
|
2017-07-30 17:48:23 +02:00
|
|
|
}
|
2016-11-01 22:52:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-28 10:58:56 +01:00
|
|
|
// validateInput validates the server/port/nick configuration. Returns a *girc.Client if successful
|
|
|
|
func (b *Birc) getClient() (*girc.Client, error) {
|
|
|
|
server, portstr, err := net.SplitHostPort(b.GetString("Server"))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
port, err := strconv.Atoi(portstr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-10-16 23:59:39 +02:00
|
|
|
user := b.GetString("UserName")
|
|
|
|
if user == "" {
|
|
|
|
user = b.GetString("Nick")
|
|
|
|
}
|
2018-11-28 10:58:56 +01:00
|
|
|
// fix strict user handling of girc
|
|
|
|
for !girc.IsValidUser(user) {
|
2019-04-05 00:17:38 +02:00
|
|
|
if len(user) == 1 || len(user) == 0 {
|
2018-11-28 10:58:56 +01:00
|
|
|
user = "matterbridge"
|
|
|
|
break
|
|
|
|
}
|
|
|
|
user = user[1:]
|
|
|
|
}
|
2021-10-16 23:59:39 +02:00
|
|
|
realName := b.GetString("RealName")
|
|
|
|
if realName == "" {
|
|
|
|
realName = b.GetString("Nick")
|
|
|
|
}
|
2018-11-28 10:58:56 +01:00
|
|
|
|
2020-10-20 00:33:15 +02:00
|
|
|
debug := ioutil.Discard
|
|
|
|
if b.GetInt("DebugLevel") == 2 {
|
|
|
|
debug = b.Log.Writer()
|
|
|
|
}
|
|
|
|
|
2020-10-21 01:14:13 +02:00
|
|
|
pingDelay, err := time.ParseDuration(b.GetString("pingdelay"))
|
|
|
|
if err != nil || pingDelay == 0 {
|
|
|
|
pingDelay = time.Minute
|
|
|
|
}
|
|
|
|
|
|
|
|
b.Log.Debugf("setting pingdelay to %s", pingDelay)
|
|
|
|
|
2018-11-28 10:58:56 +01:00
|
|
|
i := girc.New(girc.Config{
|
|
|
|
Server: server,
|
|
|
|
ServerPass: b.GetString("Password"),
|
|
|
|
Port: port,
|
|
|
|
Nick: b.GetString("Nick"),
|
|
|
|
User: user,
|
2021-10-16 23:59:39 +02:00
|
|
|
Name: realName,
|
2018-11-28 10:58:56 +01:00
|
|
|
SSL: b.GetBool("UseTLS"),
|
|
|
|
TLSConfig: &tls.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"), ServerName: server}, //nolint:gosec
|
2020-10-21 01:14:13 +02:00
|
|
|
PingDelay: pingDelay,
|
2020-06-24 23:57:37 +02:00
|
|
|
// skip gIRC internal rate limiting, since we have our own throttling
|
2020-12-30 18:21:32 +01:00
|
|
|
AllowFlood: true,
|
|
|
|
Debug: debug,
|
|
|
|
SupportedCaps: map[string][]string{"overdrivenetworks.com/relaymsg": nil, "draft/relaymsg": nil},
|
2018-11-28 10:58:56 +01:00
|
|
|
})
|
|
|
|
return i, nil
|
|
|
|
}
|
|
|
|
|
2017-10-20 22:22:13 +02:00
|
|
|
func (b *Birc) endNames(client *girc.Client, event girc.Event) {
|
|
|
|
channel := event.Params[1]
|
2016-08-14 21:48:51 +02:00
|
|
|
sort.Strings(b.names[channel])
|
|
|
|
maxNamesPerPost := (300 / b.nicksPerRow()) * b.nicksPerRow()
|
|
|
|
for len(b.names[channel]) > maxNamesPerPost {
|
2021-05-27 21:45:23 +02:00
|
|
|
b.Remote <- config.Message{
|
|
|
|
Username: b.Nick, Text: b.formatnicks(b.names[channel][0:maxNamesPerPost]),
|
|
|
|
Channel: channel, Account: b.Account,
|
|
|
|
}
|
2016-08-14 21:48:51 +02:00
|
|
|
b.names[channel] = b.names[channel][maxNamesPerPost:]
|
|
|
|
}
|
2021-05-27 21:45:23 +02:00
|
|
|
b.Remote <- config.Message{
|
|
|
|
Username: b.Nick, Text: b.formatnicks(b.names[channel]),
|
|
|
|
Channel: channel, Account: b.Account,
|
|
|
|
}
|
2016-08-14 21:48:51 +02:00
|
|
|
b.names[channel] = nil
|
2017-10-20 22:22:13 +02:00
|
|
|
b.i.Handlers.Clear(girc.RPL_NAMREPLY)
|
|
|
|
b.i.Handlers.Clear(girc.RPL_ENDOFNAMES)
|
2016-08-14 21:48:51 +02:00
|
|
|
}
|
|
|
|
|
2018-02-24 23:56:35 +01:00
|
|
|
func (b *Birc) skipPrivMsg(event girc.Event) bool {
|
|
|
|
// Our nick can be changed
|
2017-06-18 00:13:10 +02:00
|
|
|
b.Nick = b.i.GetNick()
|
2018-02-24 23:56:35 +01:00
|
|
|
|
2017-06-18 00:13:10 +02:00
|
|
|
// freenode doesn't send 001 as first reply
|
2020-11-22 22:21:02 +01:00
|
|
|
if event.Command == "NOTICE" && len(event.Params) != 2 {
|
2018-02-24 23:56:35 +01:00
|
|
|
return true
|
2017-06-18 00:13:10 +02:00
|
|
|
}
|
2016-10-29 16:27:07 +02:00
|
|
|
// don't forward queries to the bot
|
2017-10-20 22:22:13 +02:00
|
|
|
if event.Params[0] == b.Nick {
|
2018-02-24 23:56:35 +01:00
|
|
|
return true
|
2016-10-29 16:27:07 +02:00
|
|
|
}
|
2016-10-29 16:35:16 +02:00
|
|
|
// don't forward message from ourself
|
2017-10-20 22:22:13 +02:00
|
|
|
if event.Source.Name == b.Nick {
|
2018-02-24 23:56:35 +01:00
|
|
|
return true
|
|
|
|
}
|
2020-12-30 18:21:32 +01:00
|
|
|
// don't forward messages we sent via RELAYMSG
|
|
|
|
if relayedNick, ok := event.Tags.Get("draft/relaymsg"); ok && relayedNick == b.Nick {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
// This is the old name of the cap sent in spoofed messages; I've kept this in
|
|
|
|
// for compatibility reasons
|
|
|
|
if relayedNick, ok := event.Tags.Get("relaymsg"); ok && relayedNick == b.Nick {
|
|
|
|
return true
|
|
|
|
}
|
2018-02-24 23:56:35 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-08-14 21:48:51 +02:00
|
|
|
func (b *Birc) nicksPerRow() int {
|
2016-09-18 19:21:15 +02:00
|
|
|
return 4
|
2016-08-14 21:48:51 +02:00
|
|
|
}
|
|
|
|
|
2017-10-20 22:22:13 +02:00
|
|
|
func (b *Birc) storeNames(client *girc.Client, event girc.Event) {
|
|
|
|
channel := event.Params[2]
|
2016-08-14 21:48:51 +02:00
|
|
|
b.names[channel] = append(
|
|
|
|
b.names[channel],
|
2019-02-16 17:24:04 +01:00
|
|
|
strings.Split(strings.TrimSpace(event.Last()), " ")...)
|
2016-08-14 21:48:51 +02:00
|
|
|
}
|
|
|
|
|
2018-11-08 00:29:30 +01:00
|
|
|
func (b *Birc) formatnicks(nicks []string) string {
|
2018-11-14 22:43:52 +01:00
|
|
|
return strings.Join(nicks, ", ") + " currently on IRC"
|
2016-08-14 21:48:51 +02:00
|
|
|
}
|