Skip to content

Commit

Permalink
Fix bug when using commands
Browse files Browse the repository at this point in the history
  • Loading branch information
bb4L committed Dec 30, 2019
1 parent dbe703c commit 8d0f66b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='telegram-task-bot',
version='0.0.8',
version='0.0.9',
license='BSD-3',
description='rpi-radio-alarm library',
long_description=open('README.md').read(),
Expand Down
6 changes: 2 additions & 4 deletions telegramtaskbot/Bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, Filters, CallbackQueryHandler

from telegramtaskbot.Task import Task

logging.basicConfig(filename='telegramTaskBot.log', filemode='a',
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
Expand All @@ -36,8 +34,8 @@ def __init__(self, tasks: []):
self.cmd_fun[task.job_stop_name] = task.stop
self.default_button_list.extend(task.get_inline_keyboard())
if task.generic:
self.dispatcher.add_handler(CommandHandler(task.job_start_name, task.start, default_filter))
self.dispatcher.add_handler(CommandHandler(task.job_stop_name, task.stop, default_filter))
self.dispatcher.add_handler(CommandHandler(task.job_start_name, task.start_command, default_filter))
self.dispatcher.add_handler(CommandHandler(task.job_stop_name, task.stop_command, default_filter))

self.load_from_json()

Expand Down
6 changes: 6 additions & 0 deletions telegramtaskbot/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def start(self, jobs: List[telegram.ext.Job], update: telegram.Update, context:
text=f'Setting the job {self.job_name} up')
self._start(jobs, context.job_queue, update.callback_query.message.chat_id)

def start_command(self, update: telegram.Update, context: telegram.ext.CallbackContext):
raise NotImplementedError

def stop_command(self, update: telegram.Update, context: telegram.ext.CallbackContext):
raise NotImplementedError

def _start(self, jobs: List[telegram.ext.Job], job_queue: JobQueue, chat_id):
new_job = job_queue.run_repeating(self.callback, self.repeat_time, context=chat_id, first=self.first_time)
new_job.name = self.job_name
Expand Down

0 comments on commit 8d0f66b

Please sign in to comment.