Skip to content

Commit

Permalink
fix little
Browse files Browse the repository at this point in the history
  • Loading branch information
kitech committed May 9, 2018
1 parent 534123f commit 7178b04
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bridge/tox/tox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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)
}
Expand Down
10 changes: 6 additions & 4 deletions bridge/tox/tox_auto_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -176,8 +177,8 @@ var nethlpbots = []string{
"DD7A68B345E0AA918F3544AA916B5CA6AED6DE80389BFF1EF7342DACD597943D62BDEED1FC67", // my echobot
"03F47F0AE26BE32C73579CBA2C5421A159EDFF74535A7E8C6480398D93A0EA2E02B1B20B80D7", // DobroBot
"A922A51E1C91205B9F7992E2273107D47C72E8AE909C61C28A77A4A2A115431B14592AB38A3B", // toxirc
//, // [email protected],
//, // [email protected],
kalinabot, // [email protected],
lainbot, // [email protected],
}

// TODO sync锁
Expand Down Expand Up @@ -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 ([email protected])": "invite 3",
// "Russian Tox Chat ([email protected])": "invite 3",
// "test autobot": "invite 4",
// "Russian Tox Chat (Use [email protected] or 12EDB939AA529641CE53830B518D6EB30241868EE0E5023C46A372363CAEC91C2C948AEFE4EB": "invite 5",
}
Expand All @@ -428,7 +429,8 @@ var skipTitleChangeWhiteList *hashset.Set = hashset.New()

func init() {
skipTitleChangeWhiteList.Add(
"415732B8A549B2A1F9A278B91C649B9E30F07330E8818246375D19E52F927C57", // lainbot
lainbot[:64], // lainbot
kalinabot[:64], // kalinabot
"398C8161D038FD328A573FFAA0F5FAAF7FFDE5E8B4350E7D15E6AFD0B993FC52" /* admin */)
}

Expand Down
17 changes: 16 additions & 1 deletion bridge/tox/util.go
Original file line number Diff line number Diff line change
@@ -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{}) {
Expand All @@ -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
}

0 comments on commit 7178b04

Please sign in to comment.