Add Matrix->WhatsApp replies and other stuff

This commit is contained in:
Tulir Asokan
2018-08-26 00:26:24 +03:00
parent 6d08a5ff6c
commit 060516f9cf
5 changed files with 303 additions and 103 deletions

View File

@ -32,7 +32,7 @@ import (
func (bridge *Bridge) ParsePuppetMXID(mxid types.MatrixUserID) (types.MatrixUserID, types.WhatsAppID, bool) {
userIDRegex, err := regexp.Compile(fmt.Sprintf("^@%s:%s$",
bridge.Config.Bridge.FormatUsername("([0-9]+)", "([0-9]+)"),
bridge.Config.Bridge.FormatUsername("(.+)", "([0-9]+)"),
bridge.Config.Homeserver.Domain))
if err != nil {
bridge.Log.Warnln("Failed to compile puppet user ID regex:", err)
@ -138,6 +138,10 @@ type Puppet struct {
MXID types.MatrixUserID
}
func (puppet *Puppet) PhoneNumber() string {
return strings.Replace(puppet.JID, whatsapp_ext.NewUserSuffix, "", 1)
}
func (puppet *Puppet) Intent() *appservice.IntentAPI {
return puppet.bridge.AppService.Intent(puppet.MXID)
}