curl -s https://www.kufar.by/item/137097961 | grep 'kf-Fqrg-c7f38' && echo 'Есть kf-Fqrg-c7f38' || echo 'Нету kf-Fqrg-c7f38'
Нету kf-Fqrg-c7f38
from telegram.ext import Updater, CallbackContext
u = Updater(config.TOKEN, use_context=True)
j = u.job_queue
@bot.message_handler(commands=['start'])
def welcome(message):
bot.send_message(message.chat.id, '...')
j.run_once(callback_1, 10, context=message.chat.id)
def callback_1(context: CallbackContext):
context.bot.send_message(chat_id=context.job.context, text='...')
class StoppableThread(threading.Thread):
"""Thread class with a stop() method. The thread itself has to check
regularly for the stopped() condition."""
def __init__(self, *args, **kwargs):
super(StoppableThread, self).__init__(*args, **kwargs)
self._stop_event = threading.Event()
def stop(self):
self._stop_event.set()
def stopped(self):
return self._stop_event.is_set()
with open('file','r') as f:
text = f.read()
import asyncio
async def async_io():
print("async_io start")
result = 100
print("async_io end")
return result
async def async_db_query(data):
print("async_db_query start")
result = await asyncio.sleep(1, result=500)
print("async_db_query end")
return result
async def async_calculating(data):
print("async_calculating start")
res = 0
for i in range(1000):
res += 1
print("async_calculating end")
return res
async def task():
print("Task start")
res_async = await async_io()
res = await asyncio.gather(
async_db_query(res_async),
async_calculating(res_async)
)
task_calc = sum(res)
print(f"Task end. Result: {task_calc}")
return task_calc
loop = asyncio.get_event_loop()
loop.create_task(task())
loop.run_forever()
greet = wrapper
, поэтому, когда происходит вызов greet(), вместо этого вызывается wrapper(), а не определенный в изначальном коде greet. Какой chat_id надо указывать в телеграмм боте?
FAQ
Can I use celery? -- at the moment the answer is no. We're working on it.
Can I just use threads? -- we don't support threads in web apps, no