commit 4b432002b7ed5707e75549f26930c85c0c103797
parent 33f8eddf1c01f213cbf7634817d6279863cd1b7a
Author: Dominik Schmidt <das1993@hotmail.com>
Date: Mon, 19 Feb 2018 20:38:52 +0000
Forward the Telegram-messages also if it is a bot-command not meant for us.
Diffstat:
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/bot.d b/src/bot.d
@@ -339,16 +339,26 @@ struct Bot{
telegram_channels[chatid]=TelegramUser(j["chat"]);
}
}
- if(msg.skipOver("/")){
+ void forward_msg(){
+ auto irc_chans=lut.telegram(chatid);
+ if(irc_chans.length==0){
+ warning("Input on not-connected telegram-channel "~j["chat"].toPrettyString);
+ }
+ foreach(chan; irc_chans){
+ ircClient.send(chan, TelegramToIRC(j));
+ }
+ }
+ if(msg.front=='/'){
trace("Bot command received");
try{
auto split=msg.findSplit(" ");
auto cmdbot=split[0].findSplit("@");
if(cmdbot[1].length!=0 && cmdbot[2]!=telegram.botName){
trace("Not one of our commands");
+ forward_msg();
}
else{
- switch(cmdbot[0]){
+ switch(cmdbot[0][1..$]){
case "link":
link(split[2], chatid);
ircClient.notice(split[2], "Linked with "~chatid.to!string);
@@ -375,13 +385,7 @@ struct Bot{
}
}
else{
- auto irc_chans=lut.telegram(chatid);
- if(irc_chans.length==0){
- warning("Input on not-connected telegram-channel "~j["chat"].toPrettyString);
- }
- foreach(chan; irc_chans){
- ircClient.send(chan, TelegramToIRC(j));
- }
+ forward_msg();
}
};
}