forked from notfullmetal/telegram_gcloner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a0ed03
commit 49f96d3
Showing
5 changed files
with
251 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
import re | ||
|
||
from telegram.ext import Dispatcher, CallbackQueryHandler | ||
|
||
from utils.helper import alert_users | ||
from utils.restricted import restricted | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
regex_stop_task = r'^stop_task,(\d+)' | ||
|
||
|
||
def init(dispatcher: Dispatcher): | ||
"""Provide handlers initialization.""" | ||
dispatcher.add_handler(CallbackQueryHandler(stop_task, pattern=regex_stop_task)) | ||
|
||
|
||
@restricted | ||
def stop_task(update, context): | ||
query = update.callback_query | ||
if query.data: | ||
match = re.search(regex_stop_task, query.data) | ||
if match: | ||
thread_id = int(match.group(1)) | ||
tasks = context.user_data.get('tasks', None) | ||
if tasks: | ||
for t in tasks: | ||
if t.native_id == thread_id: | ||
t.kill() | ||
return | ||
alert_users(context, update.effective_user, 'invalid query data', query.data) | ||
query.answer(text='哟呵', show_alert=True) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.