From e63aaab4247e6fb83e2713ba47404a834f48a44f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 27 Feb 2017 23:16:42 +0100 Subject: [PATCH] Created a basic bot --- basicbot.py | 11 +++++++++++ telegram.py | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 basicbot.py diff --git a/basicbot.py b/basicbot.py new file mode 100644 index 00000000..7e589d05 --- /dev/null +++ b/basicbot.py @@ -0,0 +1,11 @@ +import asyncio +loop = asyncio.get_event_loop() +import telegram + +b = telegram.Bot("ciao pizza") + +async def print_message(bot, update): + print(update.message.content) + +b.commands["echo"] = print_message +b.run() \ No newline at end of file diff --git a/telegram.py b/telegram.py index 391b1a0f..498f1af8 100644 --- a/telegram.py +++ b/telegram.py @@ -28,7 +28,7 @@ class Bot: def __hash__(self): return hash(self.token) - async def run(self): + def run(self): """Run the bot automatically.""" while True: loop.run_until_complete(self.get_updates()) @@ -368,7 +368,3 @@ class Location: class Venue: def __init__(self, init_dict): raise NotImplementedError("Not yet.") - - -b = Bot(os.environ["royalbottelegram"]) -loop.run_until_complete(b.run()) \ No newline at end of file