Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 1f269230984f80232df971bcc9afe63818f2cf80 Author: Kufat <kufat@kufat.net> Date: Sat Nov 26 18:01:10 2022 +0000 Allow substitution of bot's nick in RunCommands (irc) (#1890) * Allow substitution of bot's nick in RunCommands * Tweak description of "{BOTNICK}" Made the description of "{BOTNICK}" consistent with that of other keywords diff --git a/bridge/irc/handlers.go b/bridge/irc/handlers.go index 987df2c..74db768 100644 --- a/bridge/irc/handlers.go +++ b/bridge/irc/handlers.go @@ -2436 +2437 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {    func (b *Birc) handleRunCommands() {   for _, cmd := range b.GetStringSlice("RunCommands") { + cmd = strings.ReplaceAll(cmd, "{BOTNICK}", b.Nick)   if err := b.i.Cmd.SendRaw(cmd); err != nil {   b.Log.Errorf("RunCommands %s failed: %s", cmd, err)   } diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 97b27d7..2080068 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -12210 +12211 @@ RejoinDelay=0  #Only works in IRC right now.  ColorNicks=false   -#RunCommands allows you to send RAW irc commands after connection +#RunCommands allows you to send RAW irc commands after connection. +#The string {BOTNICK} (case sensitive) will be replaced with the bot's current nickname.  #Array of strings  #OPTIONAL (default empty) -RunCommands=["PRIVMSG user hello","PRIVMSG chanserv something"] +RunCommands=["PRIVMSG user hello","PRIVMSG chanserv something", "MODE {BOTNICK} +B"]    #PingDelay specifies how long to wait to send a ping to the irc server.  #You can use s for second, m for minute