Compare commits

..

No commits in common. "811f38929320ace07d52656d09cc44551d7fd90c" and "f7034fa2c2c93e7c5ec3c3738d836d5d095c831d" have entirely different histories.

6 changed files with 6 additions and 24 deletions

View File

@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.15.x, 1.18.x, 1.19.x]
go-version: [1.13.x, 1.15.x, 1.16.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:

View File

@ -23,7 +23,6 @@ http_port: 8000
# Connect to this IRC host/port.
#
# Note: SSL is enabled by default, use "irc_use_ssl: no" to disable.
# Set "irc_verify_ssl: no" to accept invalid SSL certificates (not recommended)
irc_host: irc.example.com
irc_port: 7000
# Optionally set the server password
@ -76,11 +75,6 @@ nickserv_identify_patterns:
- "identify via /msg NickServ identify <password>"
- "type /msg NickServ IDENTIFY password"
- "authenticate yourself to services with the IDENTIFY command"
# Rarely NickServ or ChanServ is reached at a specific hostname. Specify an
# override here
nickserv_name: NickServ
chanserv_name: ChanServ
```
Running the bot (assuming *$GOPATH* and *$PATH* are properly setup for go):

View File

@ -49,9 +49,7 @@ type Config struct {
UsePrivmsg bool `yaml:"use_privmsg"`
AlertBufferSize int `yaml:"alert_buffer_size"`
NickservName string `yaml:"nickserv_name"`
NickservIdentifyPatterns []string `yaml:"nickserv_identify_patterns"`
ChanservName string `yaml:"chanserv_name"`
}
func LoadConfig(configFile string) (*Config, error) {
@ -70,14 +68,12 @@ func LoadConfig(configFile string) (*Config, error) {
MsgOnce: false,
UsePrivmsg: false,
AlertBufferSize: 2048,
NickservName: "NickServ",
NickservIdentifyPatterns: []string{
"Please choose a different nickname, or identify via",
"identify via /msg NickServ identify <password>",
"type /msg NickServ IDENTIFY password",
"authenticate yourself to services with the IDENTIFY command",
},
ChanservName: "ChanServ",
}
if configFile != "" {

6
irc.go
View File

@ -82,7 +82,6 @@ type IRCNotifier struct {
Nick string
NickPassword string
NickservName string
NickservIdentifyPatterns []string
Client *irc.Conn
@ -122,7 +121,6 @@ func NewIRCNotifier(config *Config, alertMsgs chan AlertMsg, delayerMaker Delaye
notifier := &IRCNotifier{
Nick: config.IRCNick,
NickPassword: config.IRCNickPass,
NickservName: config.NickservName,
NickservIdentifyPatterns: config.NickservIdentifyPatterns,
Client: client,
AlertMsgs: alertMsgs,
@ -189,7 +187,7 @@ func (n *IRCNotifier) HandleNickservMsg(msg string) {
logging.Debug("Checking if NickServ message matches identify request '%s'", identifyPattern)
if strings.Contains(cleanedMsg, identifyPattern) {
logging.Info("Handling NickServ request to IDENTIFY")
n.Client.Privmsgf(n.NickservName, "IDENTIFY %s", n.NickPassword)
n.Client.Privmsgf("NickServ", "IDENTIFY %s", n.NickPassword)
return
}
}
@ -205,7 +203,7 @@ func (n *IRCNotifier) MaybeGhostNick() {
if currentNick != n.Nick {
logging.Info("My nick is '%s', sending GHOST to NickServ to get '%s'",
currentNick, n.Nick)
n.Client.Privmsgf(n.NickservName, "GHOST %s %s", n.Nick,
n.Client.Privmsgf("NickServ", "GHOST %s %s", n.Nick,
n.NickPassword)
time.Sleep(n.NickservDelayWait)

View File

@ -42,8 +42,6 @@ func makeTestIRCConfig(IRCPort int) *Config {
NickservIdentifyPatterns: []string{
"identify yourself ktnxbye",
},
NickservName: "NickServ",
ChanservName: "ChanServ",
}
}

View File

@ -31,7 +31,6 @@ const (
type channelState struct {
channel IRCChannel
chanservName string
client *irc.Conn
delayer Delayer
@ -45,7 +44,7 @@ type channelState struct {
mu sync.Mutex
}
func newChannelState(channel *IRCChannel, client *irc.Conn, delayerMaker DelayerMaker, timeTeller TimeTeller, chanservName string) *channelState {
func newChannelState(channel *IRCChannel, client *irc.Conn, delayerMaker DelayerMaker, timeTeller TimeTeller) *channelState {
delayer := delayerMaker.NewDelayer(ircJoinMaxBackoffSecs, ircJoinBackoffResetSecs, time.Second)
return &channelState{
@ -56,7 +55,6 @@ func newChannelState(channel *IRCChannel, client *irc.Conn, delayerMaker Delayer
joinDone: make(chan struct{}),
joined: false,
joinUnsetSignal: make(chan bool),
chanservName: chanservName,
}
}
@ -108,7 +106,7 @@ func (c *channelState) join(ctx context.Context) {
}
// Try to unban ourselves, just in case
c.client.Privmsgf(c.chanservName, "UNBAN %s", c.channel.Name)
c.client.Privmsgf("ChanServ", "UNBAN %s", c.channel.Name)
c.client.Join(c.channel.Name, c.channel.Password)
logging.Info("Channel %s monitor: join request sent", c.channel.Name)
@ -158,7 +156,6 @@ type ChannelReconciler struct {
timeTeller TimeTeller
channels map[string]*channelState
chanservName string
stopCtx context.Context
stopCtxCancel context.CancelFunc
@ -174,7 +171,6 @@ func NewChannelReconciler(config *Config, client *irc.Conn, delayerMaker Delayer
delayerMaker: delayerMaker,
timeTeller: timeTeller,
channels: make(map[string]*channelState),
chanservName: config.ChanservName,
}
reconciler.registerHandlers()
@ -231,7 +227,7 @@ func (r *ChannelReconciler) HandleKick(nick string, channel string) {
}
func (r *ChannelReconciler) unsafeAddChannel(channel *IRCChannel) *channelState {
c := newChannelState(channel, r.client, r.delayerMaker, r.timeTeller, r.chanservName)
c := newChannelState(channel, r.client, r.delayerMaker, r.timeTeller)
r.stopWg.Add(1)
go c.Monitor(r.stopCtx, &r.stopWg)