BastliBridge

A bot framework bridgin multiple IM protocols, and mail
git clone git://xatko.vsos.ethz.ch/BastliBridge.git
Log | Files | Refs | Submodules

commit 94b54874275494fea2cf863f86b45a7ecf758801
parent 7d728dd91437f41bd0dd2512cdbf4e0c31285070
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Wed, 13 Sep 2017 20:02:35 +0200

Only respond to telegram-commands, if they're meant for us.

Diffstat:
src/telegram.d | 36+++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/telegram.d b/src/telegram.d @@ -462,21 +462,27 @@ struct Bot{ trace("Bot command received"); try{ auto split=msg.findSplit(" "); - switch(split[0].findSplit("@")[0]){ - case "link": - link(split[2], chatid); - ircClient.notice(split[2], "Linked with "~chatid.to!string); - break; - case "links": - telegram.send(chatid, lut.telegram(chatid).join(", ")); - break; - case "unlink": - unlink(split[2], chatid); - ircClient.notice(split[2], "Unlinked with "~chatid.to!string); - break; - default: - //telegram.send(chatid, split[0]~": Unknown command"); - break; + auto cmdbot=split[0].findSplit("@"); + if(cmdbot[1].length==0 && cmdbot[2]!=telegram.botName){ + trace("Not one of our commands"); + } + else{ + switch(cmdbot[0]){ + case "link": + link(split[2], chatid); + ircClient.notice(split[2], "Linked with "~chatid.to!string); + break; + case "links": + telegram.send(chatid, lut.telegram(chatid).join(", ")); + break; + case "unlink": + unlink(split[2], chatid); + ircClient.notice(split[2], "Unlinked with "~chatid.to!string); + break; + default: + //telegram.send(chatid, split[0]~": Unknown command"); + break; + } } } catch(Exception e){