@client.event
async def on_voice_state_update(member, before, after):
members_count = len(client.get_channel(908270672290132002).members)
client.get_channel(908270672290132000).edit(name = str(members_count))
import websocket
import _thread
import json
def on_message(ws, message):
data = json.loads(json.loads(message)['data'])
print(data['bid'], data['ask'])
def on_error(ws, error):
print(error)
def on_close(ws, close_status_code, close_msg):
print("### closed ###")
def on_open(ws):
def run(*args):
ws.send(json.dumps({"event":"pusher:subscribe","data":{"channel":"45076691096786116"}}))
_thread.start_new_thread(run, ())
if __name__ == "__main__":
websocket.enableTrace(False)
ws = websocket.WebSocketApp("wss://prod-pusher.backend-capital.com/app/MvtsstCbm?protocol=7&client=js&version=4.2.2&flash=false",
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.run_forever()
until_date
, который отвечает за время блокировки? При достижении времени в until_date
ограничения с пользователя снимаются bot.send_photo
- никак. Существует отдельный метод sendMediaGroup bot.send_photo(user[0], 'URL афиши', caption=message.text[message.text.find(' '):], parse_mode='Markdown')
bot.process_commands(message)
в конец on_messageregister_next_step_handler(message, my_func, password)
def register_next_step_handler(
self, message: types.Message, callback: Callable, *args, **kwargs) -> None:
"""
Registers a callback function to be notified when new message arrives after `message`.
Warning: In case `callback` as lambda function, saving next step handlers will not work.
:param message: The message for which we want to handle new message in the same chat.
:param callback: The callback function which next new message arrives.
:param args: Args to pass in callback func
:param kwargs: Args to pass in callback func
"""
@bot.channel_post_handler(content_types=['document'])
response = bot.getUpdates()
for resp in response:
print(resp['message'].get('text'))
@bot.callback_query_handler(func=lambda call: call.data != "short")
def callback_inline(call): #функция обработчик callback данных пользовательского выбора
try:
if call.message:
if call.data == "Yes": #если выбор "Да" то запускается функция со второй клавиатурой
return response_data(call.message.chat.id)
elif call.data == "No":
bot.send_message(call.message.chat.id, "Попробуйте ещё раз")
except Exception as e:
print(repr(e))
call.data == ‘long’