We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] Error in Telegram: "AttributeError: 'module' object has no attribute 'now'"
### Expected Behavior

<!-- Tell us what you expect to happen -->

Bot running with Telegram enabled
### Actual Behavior

<!-- Tell us what is happening -->

Bot not starting due to error message
### Your FULL config.json (remove your username, password, gmapkey and any other private info)

<!-- Provide your FULL config file, feel free to use services such as pastebin.com to reduce clutter -->

http://pastebin.com/5nQC2ceh
### Output when issue occurred

<!-- Provide a reasonable sample from your output log (not just the error message), feel free to use services such as pastebin.com to reduce clutter -->

Traceback (most recent call last):
  File "pokecli.py", line 781, in <module>
    main()
  File "pokecli.py", line 128, in main
    bot = start_bot(bot, config)
  File "pokecli.py", line 88, in start_bot
    initialize_task(bot, config)
  File "pokecli.py", line 79, in initialize_task
    tree = TreeConfigBuilder(bot, config.raw_tasks).build()
  File "/PokemonGo-Bot/pokemongo_bot/tree_config_builder.py", line 79, in build
    instance = worker(self.bot, task_config)
  File "/PokemonGo-Bot/pokemongo_bot/base_task.py", line 23, in **init**
    self.initialize()
  File "/PokemonGo-Bot/pokemongo_bot/cell_workers/telegram_task.py", line 42, in initialize
    self.next_job=datetime.now() + timedelta(seconds=self.min_interval)
AttributeError: 'module' object has no attribute 'now'
### Steps to Reproduce

<!-- Tell us the steps you have taken to reproduce the issue -->

Start the bot with the above config.
### Other Information

OS: CentOS

<!-- Tell us what Operating system you're using --> 

Branch: dev

<!-- dev or master --> 

Git Commit: 9e81c6ed90d79e181599ec7f0a0cfa2ecd4d09f5

<!-- run 'git log -n 1 --pretty=format:"%H"' --> 

Python Version: Python 2.7.5

<!-- run 'python -V' and paste it here) --> 

Any other relevant files/configs (eg: path files) 

<!-- Anything else which may be of relevance -->

<!-- ===============END OF ISSUE SECTION=============== -->


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pokemongo_bot/cell_workers/telegram_task.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 import datetime
3 import telegram
4 import os
5 import logging
6 import json
7 from pokemongo_bot.base_task import BaseTask
8 from pokemongo_bot.base_dir import _base_dir
9 from pokemongo_bot.event_handlers import TelegramHandler
10 
11 from pprint import pprint
12 import re
13 
14 class FileIOException(Exception):
15     pass
16 
17 class TelegramTask(BaseTask):
18     SUPPORTED_TASK_API_VERSION = 1
19     update_id = None
20     tbot = None
21     min_interval=None
22     next_job=None
23     
24     def initialize(self):
25         if not self.enabled:
26             return
27         api_key = self.bot.config.telegram_token
28         if api_key == None:
29             self.emit_event(
30                 'config_error',
31                 formatted='api_key not defined.'
32             )
33             return
34         self.tbot = telegram.Bot(api_key)
35         if self.config.get('master',None):
36             self.bot.event_manager.add_handler(TelegramHandler(self.tbot,self.config.get('master',None),self.config.get('alert_catch')))
37         try:
38             self.update_id = self.tbot.getUpdates()[0].update_id
39         except IndexError:
40             self.update_id = None
41         self.min_interval=self.config.get('min_interval',120)
42         self.next_job=datetime.now() + timedelta(seconds=self.min_interval)
43     def work(self):
44         if not self.enabled:
45             return
46         if datetime.now()<self.next_job:
47             return
48         self.next_job=datetime.now() + timedelta(seconds=self.min_interval)
49         for update in self.tbot.getUpdates(offset=self.update_id, timeout=10):
50             self.update_id = update.update_id+1
51             if update.message:
52                 self.bot.logger.info("message from {} ({}): {}".format(update.message.from_user.username, update.message.from_user.id, update.message.text))
53                 if self.config.get('master',None) and self.config.get('master',None) not in [update.message.from_user.id, "@{}".format(update.message.from_user.username)]:
54                     self.emit_event( 
55                             'debug', 
56                             formatted="Master wrong: expecting {}, got {}({})".format(self.config.get('master',None), update.message.from_user.username, update.message.from_user.id))
57                     continue
58                 else:
59                     if not re.match(r'^[0-9]+$', "{}".format(self.config['master'])): # master was not numeric...
60                         self.config['master'] = update.message.chat_id
61                         idx = (i for i,v in enumerate(self.bot.event_manager._handlers) if type(v) is TelegramHandler).next()
62                         self.bot.event_manager._handlers[idx] = TelegramHandler(self.tbot,self.config['master'], self.config.get('alert_catch'))
63                         
64 
65 
66                 if update.message.text == "/info":
67                     stats = self._get_player_stats()
68                     if stats:
69                         with self.bot.database as conn:
70                             cur = conn.cursor()
71                             cur.execute("SELECT DISTINCT COUNT(encounter_id) FROM catch_log WHERE dated >= datetime('now','-1 day')")
72                             catch_day = cur.fetchone()[0]
73                             cur.execute("SELECT DISTINCT COUNT(pokestop) FROM pokestop_log WHERE dated >= datetime('now','-1 day')")
74                             ps_day = cur.fetchone()[0]
75                             res = (
76                                 "*"+self.bot.config.username+"*",
77                                 "_Level:_ "+str(stats["level"]),
78                                 "_XP:_ "+str(stats["experience"])+"/"+str(stats["next_level_xp"]),
79                                 "_Pokemons Captured:_ "+str(stats["pokemons_captured"])+" ("+str(catch_day)+" _last 24h_)",
80                                 "_Poke Stop Visits:_ "+str(stats["poke_stop_visits"])+" ("+str(ps_day)+" _last 24h_)",
81                                 "_KM Walked:_ "+str(stats["km_walked"])
82                             )
83                             self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="\n".join(res))
84                             self.tbot.send_location(chat_id=update.message.chat_id, latitude=self.bot.api._position_lat, longitude=self.bot.api._position_lng)
85                     else:
86                         self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="Stats not loaded yet\n")
87                 elif update.message.text == "/start" or update.message.text == "/help":
88                     res = (
89                         "Commands: ",
90                         "/info - info about bot"
91                     )
92                     self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="\n".join(res))
93 
94     def _get_player_stats(self):
95         """
96         Helper method parsing the bot inventory object and returning the player stats object.
97         :return: The player stats object.
98         :rtype: dict
99         """
100         web_inventory = os.path.join(_base_dir, "web", "inventory-%s.json" % self.bot.config.username)
101         
102         try:
103             with open(web_inventory, "r") as infile:
104                 json_inventory = json.load(infile)
105         except ValueError as e:
106             # Unable to read json from web inventory
107             # File may be corrupt. Create a new one.  
108             self.bot.logger.info('[x] Error while opening inventory file for read: %s' % e)
109             json_inventory = []
110         except:
111             raise FileIOException("Unexpected error reading from {}".web_inventory)
112             
113         return next((x["inventory_item_data"]["player_stats"]
114                      for x in json_inventory
115                      if x.get("inventory_item_data", {}).get("player_stats", {})),
116                     None)
117
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pokemongo_bot/cell_workers/telegram_task.py b/pokemongo_bot/cell_workers/telegram_task.py
--- a/pokemongo_bot/cell_workers/telegram_task.py
+++ b/pokemongo_bot/cell_workers/telegram_task.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
-import datetime
+from datetime import datetime
+from datetime import timedelta
 import telegram
 import os
 import logging

{"golden_diff": "diff --git a/pokemongo_bot/cell_workers/telegram_task.py b/pokemongo_bot/cell_workers/telegram_task.py\n--- a/pokemongo_bot/cell_workers/telegram_task.py\n+++ b/pokemongo_bot/cell_workers/telegram_task.py\n@@ -1,5 +1,6 @@\n # -*- coding: utf-8 -*-\n-import datetime\n+from datetime import datetime\n+from datetime import timedelta\n import telegram\n import os\n import logging\n", "issue": "[BUG] Error in Telegram: \"AttributeError: 'module' object has no attribute 'now'\"\n### Expected Behavior\n\n<!-- Tell us what you expect to happen -->\n\nBot running with Telegram enabled\n### Actual Behavior\n\n<!-- Tell us what is happening -->\n\nBot not starting due to error message\n### Your FULL config.json (remove your username, password, gmapkey and any other private info)\n\n<!-- Provide your FULL config file, feel free to use services such as pastebin.com to reduce clutter -->\n\nhttp://pastebin.com/5nQC2ceh\n### Output when issue occurred\n\n<!-- Provide a reasonable sample from your output log (not just the error message), feel free to use services such as pastebin.com to reduce clutter -->\n\nTraceback (most recent call last):\n  File \"pokecli.py\", line 781, in <module>\n    main()\n  File \"pokecli.py\", line 128, in main\n    bot = start_bot(bot, config)\n  File \"pokecli.py\", line 88, in start_bot\n    initialize_task(bot, config)\n  File \"pokecli.py\", line 79, in initialize_task\n    tree = TreeConfigBuilder(bot, config.raw_tasks).build()\n  File \"/PokemonGo-Bot/pokemongo_bot/tree_config_builder.py\", line 79, in build\n    instance = worker(self.bot, task_config)\n  File \"/PokemonGo-Bot/pokemongo_bot/base_task.py\", line 23, in **init**\n    self.initialize()\n  File \"/PokemonGo-Bot/pokemongo_bot/cell_workers/telegram_task.py\", line 42, in initialize\n    self.next_job=datetime.now() + timedelta(seconds=self.min_interval)\nAttributeError: 'module' object has no attribute 'now'\n### Steps to Reproduce\n\n<!-- Tell us the steps you have taken to reproduce the issue -->\n\nStart the bot with the above config.\n### Other Information\n\nOS: CentOS\n\n<!-- Tell us what Operating system you're using --> \n\nBranch: dev\n\n<!-- dev or master --> \n\nGit Commit: 9e81c6ed90d79e181599ec7f0a0cfa2ecd4d09f5\n\n<!-- run 'git log -n 1 --pretty=format:\"%H\"' --> \n\nPython Version: Python 2.7.5\n\n<!-- run 'python -V' and paste it here) --> \n\nAny other relevant files/configs (eg: path files) \n\n<!-- Anything else which may be of relevance -->\n\n<!-- ===============END OF ISSUE SECTION=============== -->\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nimport datetime\nimport telegram\nimport os\nimport logging\nimport json\nfrom pokemongo_bot.base_task import BaseTask\nfrom pokemongo_bot.base_dir import _base_dir\nfrom pokemongo_bot.event_handlers import TelegramHandler\n\nfrom pprint import pprint\nimport re\n\nclass FileIOException(Exception):\n    pass\n\nclass TelegramTask(BaseTask):\n    SUPPORTED_TASK_API_VERSION = 1\n    update_id = None\n    tbot = None\n    min_interval=None\n    next_job=None\n    \n    def initialize(self):\n        if not self.enabled:\n            return\n        api_key = self.bot.config.telegram_token\n        if api_key == None:\n            self.emit_event(\n                'config_error',\n                formatted='api_key not defined.'\n            )\n            return\n        self.tbot = telegram.Bot(api_key)\n        if self.config.get('master',None):\n            self.bot.event_manager.add_handler(TelegramHandler(self.tbot,self.config.get('master',None),self.config.get('alert_catch')))\n        try:\n            self.update_id = self.tbot.getUpdates()[0].update_id\n        except IndexError:\n            self.update_id = None\n        self.min_interval=self.config.get('min_interval',120)\n        self.next_job=datetime.now() + timedelta(seconds=self.min_interval)\n    def work(self):\n        if not self.enabled:\n            return\n        if datetime.now()<self.next_job:\n            return\n        self.next_job=datetime.now() + timedelta(seconds=self.min_interval)\n        for update in self.tbot.getUpdates(offset=self.update_id, timeout=10):\n            self.update_id = update.update_id+1\n            if update.message:\n                self.bot.logger.info(\"message from {} ({}): {}\".format(update.message.from_user.username, update.message.from_user.id, update.message.text))\n                if self.config.get('master',None) and self.config.get('master',None) not in [update.message.from_user.id, \"@{}\".format(update.message.from_user.username)]:\n                    self.emit_event( \n                            'debug', \n                            formatted=\"Master wrong: expecting {}, got {}({})\".format(self.config.get('master',None), update.message.from_user.username, update.message.from_user.id))\n                    continue\n                else:\n                    if not re.match(r'^[0-9]+$', \"{}\".format(self.config['master'])): # master was not numeric...\n                        self.config['master'] = update.message.chat_id\n                        idx = (i for i,v in enumerate(self.bot.event_manager._handlers) if type(v) is TelegramHandler).next()\n                        self.bot.event_manager._handlers[idx] = TelegramHandler(self.tbot,self.config['master'], self.config.get('alert_catch'))\n                        \n\n\n                if update.message.text == \"/info\":\n                    stats = self._get_player_stats()\n                    if stats:\n                        with self.bot.database as conn:\n                            cur = conn.cursor()\n                            cur.execute(\"SELECT DISTINCT COUNT(encounter_id) FROM catch_log WHERE dated >= datetime('now','-1 day')\")\n                            catch_day = cur.fetchone()[0]\n                            cur.execute(\"SELECT DISTINCT COUNT(pokestop) FROM pokestop_log WHERE dated >= datetime('now','-1 day')\")\n                            ps_day = cur.fetchone()[0]\n                            res = (\n                                \"*\"+self.bot.config.username+\"*\",\n                                \"_Level:_ \"+str(stats[\"level\"]),\n                                \"_XP:_ \"+str(stats[\"experience\"])+\"/\"+str(stats[\"next_level_xp\"]),\n                                \"_Pokemons Captured:_ \"+str(stats[\"pokemons_captured\"])+\" (\"+str(catch_day)+\" _last 24h_)\",\n                                \"_Poke Stop Visits:_ \"+str(stats[\"poke_stop_visits\"])+\" (\"+str(ps_day)+\" _last 24h_)\",\n                                \"_KM Walked:_ \"+str(stats[\"km_walked\"])\n                            )\n                            self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text=\"\\n\".join(res))\n                            self.tbot.send_location(chat_id=update.message.chat_id, latitude=self.bot.api._position_lat, longitude=self.bot.api._position_lng)\n                    else:\n                        self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text=\"Stats not loaded yet\\n\")\n                elif update.message.text == \"/start\" or update.message.text == \"/help\":\n                    res = (\n                        \"Commands: \",\n                        \"/info - info about bot\"\n                    )\n                    self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text=\"\\n\".join(res))\n\n    def _get_player_stats(self):\n        \"\"\"\n        Helper method parsing the bot inventory object and returning the player stats object.\n        :return: The player stats object.\n        :rtype: dict\n        \"\"\"\n        web_inventory = os.path.join(_base_dir, \"web\", \"inventory-%s.json\" % self.bot.config.username)\n        \n        try:\n            with open(web_inventory, \"r\") as infile:\n                json_inventory = json.load(infile)\n        except ValueError as e:\n            # Unable to read json from web inventory\n            # File may be corrupt. Create a new one.  \n            self.bot.logger.info('[x] Error while opening inventory file for read: %s' % e)\n            json_inventory = []\n        except:\n            raise FileIOException(\"Unexpected error reading from {}\".web_inventory)\n            \n        return next((x[\"inventory_item_data\"][\"player_stats\"]\n                     for x in json_inventory\n                     if x.get(\"inventory_item_data\", {}).get(\"player_stats\", {})),\n                    None)\n", "path": "pokemongo_bot/cell_workers/telegram_task.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom datetime import datetime\nfrom datetime import timedelta\nimport telegram\nimport os\nimport logging\nimport json\nfrom pokemongo_bot.base_task import BaseTask\nfrom pokemongo_bot.base_dir import _base_dir\nfrom pokemongo_bot.event_handlers import TelegramHandler\n\nfrom pprint import pprint\nimport re\n\nclass FileIOException(Exception):\n    pass\n\nclass TelegramTask(BaseTask):\n    SUPPORTED_TASK_API_VERSION = 1\n    update_id = None\n    tbot = None\n    min_interval=None\n    next_job=None\n    \n    def initialize(self):\n        if not self.enabled:\n            return\n        api_key = self.bot.config.telegram_token\n        if api_key == None:\n            self.emit_event(\n                'config_error',\n                formatted='api_key not defined.'\n            )\n            return\n        self.tbot = telegram.Bot(api_key)\n        if self.config.get('master',None):\n            self.bot.event_manager.add_handler(TelegramHandler(self.tbot,self.config.get('master',None),self.config.get('alert_catch')))\n        try:\n            self.update_id = self.tbot.getUpdates()[0].update_id\n        except IndexError:\n            self.update_id = None\n        self.min_interval=self.config.get('min_interval',120)\n        self.next_job=datetime.now() + timedelta(seconds=self.min_interval)\n    def work(self):\n        if not self.enabled:\n            return\n        if datetime.now()<self.next_job:\n            return\n        self.next_job=datetime.now() + timedelta(seconds=self.min_interval)\n        for update in self.tbot.getUpdates(offset=self.update_id, timeout=10):\n            self.update_id = update.update_id+1\n            if update.message:\n                self.bot.logger.info(\"message from {} ({}): {}\".format(update.message.from_user.username, update.message.from_user.id, update.message.text))\n                if self.config.get('master',None) and self.config.get('master',None) not in [update.message.from_user.id, \"@{}\".format(update.message.from_user.username)]:\n                    self.emit_event( \n                            'debug', \n                            formatted=\"Master wrong: expecting {}, got {}({})\".format(self.config.get('master',None), update.message.from_user.username, update.message.from_user.id))\n                    continue\n                else:\n                    if not re.match(r'^[0-9]+$', \"{}\".format(self.config['master'])): # master was not numeric...\n                        self.config['master'] = update.message.chat_id\n                        idx = (i for i,v in enumerate(self.bot.event_manager._handlers) if type(v) is TelegramHandler).next()\n                        self.bot.event_manager._handlers[idx] = TelegramHandler(self.tbot,self.config['master'], self.config.get('alert_catch'))\n                        \n\n\n                if update.message.text == \"/info\":\n                    stats = self._get_player_stats()\n                    if stats:\n                        with self.bot.database as conn:\n                            cur = conn.cursor()\n                            cur.execute(\"SELECT DISTINCT COUNT(encounter_id) FROM catch_log WHERE dated >= datetime('now','-1 day')\")\n                            catch_day = cur.fetchone()[0]\n                            cur.execute(\"SELECT DISTINCT COUNT(pokestop) FROM pokestop_log WHERE dated >= datetime('now','-1 day')\")\n                            ps_day = cur.fetchone()[0]\n                            res = (\n                                \"*\"+self.bot.config.username+\"*\",\n                                \"_Level:_ \"+str(stats[\"level\"]),\n                                \"_XP:_ \"+str(stats[\"experience\"])+\"/\"+str(stats[\"next_level_xp\"]),\n                                \"_Pokemons Captured:_ \"+str(stats[\"pokemons_captured\"])+\" (\"+str(catch_day)+\" _last 24h_)\",\n                                \"_Poke Stop Visits:_ \"+str(stats[\"poke_stop_visits\"])+\" (\"+str(ps_day)+\" _last 24h_)\",\n                                \"_KM Walked:_ \"+str(stats[\"km_walked\"])\n                            )\n                            self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text=\"\\n\".join(res))\n                            self.tbot.send_location(chat_id=update.message.chat_id, latitude=self.bot.api._position_lat, longitude=self.bot.api._position_lng)\n                    else:\n                        self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text=\"Stats not loaded yet\\n\")\n                elif update.message.text == \"/start\" or update.message.text == \"/help\":\n                    res = (\n                        \"Commands: \",\n                        \"/info - info about bot\"\n                    )\n                    self.tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text=\"\\n\".join(res))\n\n    def _get_player_stats(self):\n        \"\"\"\n        Helper method parsing the bot inventory object and returning the player stats object.\n        :return: The player stats object.\n        :rtype: dict\n        \"\"\"\n        web_inventory = os.path.join(_base_dir, \"web\", \"inventory-%s.json\" % self.bot.config.username)\n        \n        try:\n            with open(web_inventory, \"r\") as infile:\n                json_inventory = json.load(infile)\n        except ValueError as e:\n            # Unable to read json from web inventory\n            # File may be corrupt. Create a new one.  \n            self.bot.logger.info('[x] Error while opening inventory file for read: %s' % e)\n            json_inventory = []\n        except:\n            raise FileIOException(\"Unexpected error reading from {}\".web_inventory)\n            \n        return next((x[\"inventory_item_data\"][\"player_stats\"]\n                     for x in json_inventory\n                     if x.get(\"inventory_item_data\", {}).get(\"player_stats\", {})),\n                    None)\n", "path": "pokemongo_bot/cell_workers/telegram_task.py"}]}