From 52875b6d26f98b7548f4fc8a65a9f0455490e4e6 Mon Sep 17 00:00:00 2001 From: Alexander Skovpen Date: Tue, 30 Aug 2016 09:49:47 +0300 Subject: [PATCH 1/4] add telegram check messages interval --- pokemongo_bot/cell_workers/telegram_task.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/telegram_task.py b/pokemongo_bot/cell_workers/telegram_task.py index 5c2b60787e..f9c421aff5 100644 --- a/pokemongo_bot/cell_workers/telegram_task.py +++ b/pokemongo_bot/cell_workers/telegram_task.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import datetime import telegram import os import logging @@ -17,7 +18,9 @@ class TelegramTask(BaseTask): SUPPORTED_TASK_API_VERSION = 1 update_id = None tbot = None - + min_interval=None + next_job=None + def initialize(self): if not self.enabled: return @@ -35,10 +38,14 @@ def initialize(self): self.update_id = self.tbot.getUpdates()[0].update_id except IndexError: self.update_id = None - + self.min_interval=self.config.get('min_interval',120) + self.next_job=datetime.now() + timedelta(seconds=self.min_interval) def work(self): if not self.enabled: return + if datetime.now() Date: Tue, 30 Aug 2016 09:51:48 +0300 Subject: [PATCH 2/4] config changed --- configs/config.json.example | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configs/config.json.example b/configs/config.json.example index 27257803fd..b0f7165c6e 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -12,12 +12,13 @@ "config": { "enabled": false, "master": null, + "min_interval": 120", "// old syntax, still supported: alert_catch": ["all"], - "// new syntax:": {}, - "alert_catch": { - "all": {"operator": "and", "cp": 1300, "iv": 0.95}, - "Snorlax": {"operator": "or", "cp": 900, "iv": 0.9} - } + "// new syntax:": {}, + "alert_catch": { + "all": {"operator": "and", "cp": 1300, "iv": 0.95}, + "Snorlax": {"operator": "or", "cp": 900, "iv": 0.9} + } } }, { From d14f0f6a02aa4659b8b583e5460287c58490336d Mon Sep 17 00:00:00 2001 From: Alexander Skovpen Date: Tue, 30 Aug 2016 10:03:29 +0300 Subject: [PATCH 3/4] fix config --- configs/config.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/config.json.example b/configs/config.json.example index b0f7165c6e..9cde3ee824 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -12,7 +12,7 @@ "config": { "enabled": false, "master": null, - "min_interval": 120", + "min_interval": 120, "// old syntax, still supported: alert_catch": ["all"], "// new syntax:": {}, "alert_catch": { From ed217a6eabbc4d548b91ab837cdef31631e532cd Mon Sep 17 00:00:00 2001 From: Alexander Skovpen Date: Tue, 30 Aug 2016 10:12:37 +0300 Subject: [PATCH 4/4] telegram doc update --- docs/configuration_files.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/configuration_files.md b/docs/configuration_files.md index ed615b0045..8f4abb9625 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -989,8 +989,9 @@ Bot answer on command '/info' self stats. ### Options * `telegram_token` : bot token (getting [there](https://core.telegram.org/bots#6-botfather) - one token per bot) -* `master` : id (without quotes) or username (in quotes, first character @) of bot owner, who will gett announces. -* `alert_catch` : array of pokemons, which will be announced on catch. if first array item `all` - announce all pokemons. +* `master` : id (without quotes) of bot owner, who will gett announces. +* `alert_catch` : dict of rules pokemons catch. +* `min_interval`: min interval check messages from telegram. ### Sample configuration [[back to top](#table-of-contents)] @@ -1000,9 +1001,11 @@ Bot answer on command '/info' self stats. "config": { "enabled": true, "master": 12345678, - "//master": "@username", - "alert_catch": ["Lapras","Dragonite"], - "//alert_catch": ["all"] + "min_interval": 120, + "alert_catch": { + "all": {"operator": "and", "cp": 1300, "iv": 0.95}, + "Snorlax": {"operator": "or", "cp": 900, "iv": 0.9} + } } } ```