video_note
Замена стандартного `on_message` предотвращает выполнение любых дополнительных команд. Для исправления этого добавьте добавьте строку `bot.process_commands(message)` в конце вашего `on_message`, например:
@bot.event
async def on_message(message):
# do some extra stuff here
await bot.process_commands(message)
action: Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, find_location for location data, record_video_note or upload_video_note for video notes.
при выводе предложения не склеивались слова?
re.sub("[^a-zA-Z]+", "",word)
sentence = input("Say: ")
sentence = sentence.split()
new_sentence = ''
for word in sentence:
new_sentence += word[::-1] + ' '
print(new_sentence)
import re
from datetime import datetime
sessions = {}
with open('sessions.txt', 'r', encoding='utf-8') as f:
log = f.readlines()
for line in log:
if 'Login successful' in line:
chunks = re.search(r'(.+?) Login successful from user (.+?) id_session=(.+?)$', line)
# Возможно придется подкорректировать преобразование времени, если я не угадал с форматом
login_time = datetime.strptime(chunks.group(1), '%I:%M:%S %p')
sessions[chunks.group(3)] = {'login_time': login_time, 'username': chunks.group(2)}
elif 'Closing session' in line:
chunks = re.search(r'(.+?) Closing session.+id_session=(.+?)\sreason=(.+)$', line)
logout_time = datetime.strptime(chunks.group(1), '%I:%M:%S %p')
session_id = chunks.group(2)
if session_id not in sessions:
print('Сессия {} закрыта, нет данных о входе'.format(session_id))
else:
login_time = sessions[session_id]['login_time']
username = sessions[session_id]['username']
session_time = logout_time - login_time
print('Пользователь {} завершил сессию спустя {}, причина: {}'.format(username, session_time, chunks.group(3)))
del sessions[session_id]
proxy_url = 'http://proxy.server:3128'
bot = Bot(token=TOKEN, proxy=proxy_url)
# Example of sending and receiving an event after pressing the Callback button
# Documentation: https://vk.cc/aC9JG2
import os
import logging
from vkbottle import Keyboard, Callback, GroupTypes, GroupEventType
from vkbottle.bot import Bot, Message
bot = Bot(os.environ["TOKEN"])
logging.basicConfig(level=logging.INFO)
KEYBOARD = (
Keyboard(one_time=False)
.add(Callback("Callback-кнопка", payload={"cmd": "callback"}))
.get_json()
)
@bot.on.private_message(text="/callback")
async def send_callback_button(message: Message):
await message.answer("Лови!", keyboard=KEYBOARD)
@bot.on.raw_event(GroupEventType.MESSAGE_EVENT, dataclass=GroupTypes.MessageEvent)
async def handle_message_event(event: GroupTypes.MessageEvent):
# event_data parameter accepts three object types
# "show_snackbar" type
await bot.api.messages.send_message_event_answer(
event_id=event.object.event_id,
user_id=event.object.user_id,
peer_id=event.object.peer_id,
event_data='{"type":"show_snackbar", "text":"Сейчас я исчезну"}',
)
bot.run_forever()
bot.send_photo(message.chat.id, img = open('Ржомба.png','rb'), caption = Text)
with open('Ржомба.png','rb') as f:
bot.send_photo(message.chat.id, img = f, caption = Text)
TaggedContentItem.objects.filter(tag__name__in=keys)