diff --git a/bridge/tox/tox.go b/bridge/tox/tox.go index d24abfd..b441c63 100644 --- a/bridge/tox/tox.go +++ b/bridge/tox/tox.go @@ -68,7 +68,7 @@ func New(cfg config.Protocol, account string, c chan config.Message) *Btox { store := newStorage() b.store = store - statusMessage := "matbrg for toxs. Send me the message 'info', 'help' for a full list of commands" + statusMessage := "matbrg for toxers. Send me the message 'info', 'help' for a full list of commands. code: https://github.com/envsh/matterbridge ." toxctx = xtox.NewToxContext("matbrg.tsbin", b.Nick, statusMessage) b.i = xtox.New(toxctx) SetAutoBotFeatures(b.i, FOTA_ADD_NET_HELP_BOTS| @@ -124,7 +124,7 @@ func (this *Btox) Send(msg config.Message) (string, error) { t := this.i gns, found := xtox.ConferenceFindAll(t, msg.Channel) // TODO improve needed if found { - tmsgf := msg.Username + msg.Text + tmsgf := restoreUserName(msg.Username) + msg.Text if strings.HasSuffix(msg.Text, "currently on IRC") { tmsgf = msg.Username + fmt.Sprintf("There are %d users, %s", strings.Count(msg.Text, ",")+1, msg.Text) } diff --git a/bridge/tox/tox_auto_extra.go b/bridge/tox/tox_auto_extra.go index ffe602b..7bbb2fb 100644 --- a/bridge/tox/tox_auto_extra.go +++ b/bridge/tox/tox_auto_extra.go @@ -166,6 +166,7 @@ func matchFeat(this *tox.Tox, f int) bool { //////////////////////////////// var groupbot = "56A1ADE4B65B86BCD51CC73E2CD4E542179F47959FE3E0E21B4B0ACDADE51855D34D34D37CB5" var lainbot = "415732B8A549B2A1F9A278B91C649B9E30F07330E8818246375D19E52F927C57F08A44E082F6" +var kalinabot = "12EDB939AA529641CE53830B518D6EB30241868EE0E5023C46A372363CAEC91C2C948AEFE4EB" // 帮助改进p2p网络稳定的bot列表 var nethlpbots = []string{ @@ -176,8 +177,8 @@ var nethlpbots = []string{ "DD7A68B345E0AA918F3544AA916B5CA6AED6DE80389BFF1EF7342DACD597943D62BDEED1FC67", // my echobot "03F47F0AE26BE32C73579CBA2C5421A159EDFF74535A7E8C6480398D93A0EA2E02B1B20B80D7", // DobroBot "A922A51E1C91205B9F7992E2273107D47C72E8AE909C61C28A77A4A2A115431B14592AB38A3B", // toxirc - //, // kalinaBot@toxme.io, - //, // LainBot@toxme.io, + kalinabot, // kalinaBot@toxme.io, + lainbot, // LainBot@toxme.io, } // TODO sync锁 @@ -414,7 +415,7 @@ var fixedGroupsReal = map[string]string{ "Club Cyberia": "invite 3", // "Club Cyberia: No Pedos, No Pervs": "invite 3", // "Club Cyberia: Linux General: No Pedos": "invite 4", - "Russian Tox Chat (kalina@toxme.io)": "invite 3", + // "Russian Tox Chat (kalina@toxme.io)": "invite 3", // "test autobot": "invite 4", // "Russian Tox Chat (Use kalina@toxme.io or 12EDB939AA529641CE53830B518D6EB30241868EE0E5023C46A372363CAEC91C2C948AEFE4EB": "invite 5", } @@ -428,7 +429,8 @@ var skipTitleChangeWhiteList *hashset.Set = hashset.New() func init() { skipTitleChangeWhiteList.Add( - "415732B8A549B2A1F9A278B91C649B9E30F07330E8818246375D19E52F927C57", // lainbot + lainbot[:64], // lainbot + kalinabot[:64], // kalinabot "398C8161D038FD328A573FFAA0F5FAAF7FFDE5E8B4350E7D15E6AFD0B993FC52" /* admin */) } diff --git a/bridge/tox/util.go b/bridge/tox/util.go index 757202e..e38e1be 100644 --- a/bridge/tox/util.go +++ b/bridge/tox/util.go @@ -1,6 +1,11 @@ package btox -import funk "github.com/thoas/go-funk" +import ( + "fmt" + "regexp" + + funk "github.com/thoas/go-funk" +) func DiffSlice(old, new_ interface{}) (added []interface{}, deleted []interface{}) { funk.ForEach(old, func(e interface{}) { @@ -15,3 +20,13 @@ func DiffSlice(old, new_ interface{}) (added []interface{}, deleted []interface{ }) return } + +func restoreUserName(Username string) string { + reg := `\[freenode_(.+)@matrix\]` + exp := regexp.MustCompile(reg) + mats := exp.FindAllStringSubmatch(Username, -1) + if len(mats) > 0 { + return fmt.Sprintf("[%s@irc] ", mats[0][1]) + } + return Username +}