(msg *config.Message)
| 382 | } |
| 383 | |
| 384 | func (gw *Gateway) modifyMessage(msg *config.Message) { |
| 385 | if gw.BridgeValues().General.TengoModifyMessage != "" { |
| 386 | gw.logger.Warnf("General TengoModifyMessage=%s is deprecated and will be removed in v1.20.0, please move to Tengo InMessage=%s", gw.BridgeValues().General.TengoModifyMessage, gw.BridgeValues().General.TengoModifyMessage) |
| 387 | } |
| 388 | |
| 389 | if err := modifyInMessageTengo(gw.BridgeValues().General.TengoModifyMessage, msg); err != nil { |
| 390 | gw.logger.Errorf("TengoModifyMessage failed: %s", err) |
| 391 | } |
| 392 | |
| 393 | inMessage := gw.BridgeValues().Tengo.InMessage |
| 394 | if inMessage == "" { |
| 395 | inMessage = gw.BridgeValues().Tengo.Message |
| 396 | if inMessage != "" { |
| 397 | gw.logger.Warnf("Tengo Message=%s is deprecated and will be removed in v1.20.0, please move to Tengo InMessage=%s", inMessage, inMessage) |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | if err := modifyInMessageTengo(inMessage, msg); err != nil { |
| 402 | gw.logger.Errorf("Tengo.Message failed: %s", err) |
| 403 | } |
| 404 | |
| 405 | // replace :emoji: to unicode |
| 406 | emoji.ReplacePadding = "" |
| 407 | msg.Text = emoji.Sprint(msg.Text) |
| 408 | |
| 409 | br := gw.Bridges[msg.Account] |
| 410 | // loop to replace messages |
| 411 | for _, outer := range br.GetStringSlice2D("ReplaceMessages") { |
| 412 | search := outer[0] |
| 413 | replace := outer[1] |
| 414 | // TODO move compile to bridge init somewhere |
| 415 | re, err := regexp.Compile(search) |
| 416 | if err != nil { |
| 417 | gw.logger.Errorf("regexp in %s failed: %s", msg.Account, err) |
| 418 | break |
| 419 | } |
| 420 | msg.Text = re.ReplaceAllString(msg.Text, replace) |
| 421 | } |
| 422 | |
| 423 | gw.handleExtractNicks(msg) |
| 424 | |
| 425 | // messages from api have Gateway specified, don't overwrite |
| 426 | if msg.Protocol != apiProtocol { |
| 427 | msg.Gateway = gw.Name |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | // SendMessage sends a message (with specified parentID) to the channel on the selected |
| 432 | // destination bridge and returns a message ID or an error. |
no test coverage detected