Thumbnail

rani/matterbridge.git

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

commit f914695801618d76b8982c0c6b53b0470c04e89f Author: Wim <wim@42.be> Date: Thu Feb 18 21:45:29 2016 +0000 Add support for slack username circumfix. Closes #10 diff --git a/README.md b/README.md index a6946f5..9bc7357 100644 --- a/README.md +++ b/README.md @@ -556 +557 @@ UseTLS=false  SkipTLSVerify=true  nick="matterbot"  channel="#matterbridge" +UseSlackCircumfix=false    [mattermost]  #url is your incoming webhook url (account settings - integrations - incoming webhooks) diff --git a/config.go b/config.go index 32187d2..d103888 100644 --- a/config.go +++ b/config.go @@ -813 +814 @@ import (    type Config struct {   IRC struct { - UseTLS bool - SkipTLSVerify bool - Server string - Port int - Nick string - Password string - Channel string + UseTLS bool + SkipTLSVerify bool + Server string + Port int + Nick string + Password string + Channel string + UseSlackCircumfix bool   }   Mattermost struct {   URL string diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample index b44ff8a..cf17e8a 100644 --- a/matterbridge.conf.sample +++ b/matterbridge.conf.sample @@ -56 +57 @@ UseTLS=false  SkipTLSVerify=true  nick="matterbot"  channel="#matterbridge" +UseSlackCircumfix=false    [mattermost]  url="http://yourdomain/hooks/yourhookkey" diff --git a/matterbridge.go b/matterbridge.go index a07ab30..6cf4ea2 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -1038 +10313 @@ func (b *Bridge) SendType(nick string, message string, channel string, mtype str  }    func (b *Bridge) handleMatter() { + var username string   for {   message := b.m.Receive() + username = message.UserName + ": " + if b.Config.IRC.UseSlackCircumfix { + username = "<" + message.UserName + "> " + }   cmd := strings.Fields(message.Text)[0]   switch cmd {   case "!users": @@ -1167 +1217 @@ func (b *Bridge) handleMatter() {   }   texts := strings.Split(message.Text, "\n")   for _, text := range texts { - b.i.Privmsg(b.getIRCChannel(message.Token), message.UserName+": "+text) + b.i.Privmsg(b.getIRCChannel(message.Token), username+text)   }   }  }