Answer the question
In order to leave comments, you need to log in
Why VK bot replies 2 times?
There is such a code
def write_messages(sender, message):
authorize.method('messages.send', {'chat_id': sender, 'message': message, 'random_id': get_random_id(), 'attachment': ','.join(attachments)})
def write_messages_us(user_id, message):
authorize.method('messages.send', {'peer_id': user_id, 'message': message, 'random_id': get_random_id(), 'attachment': ','.join(attachments)})
users = [id пользователя, id второго пользователя]
for id in users:
user_id=id
if id == 'id пользователя':
try:
write_messages_us(id, (re.sub(r'!Рассылка', " ", reseived_message)))
except Exception as ex:
print("Ошибка")
else:
write_messages(sender, "А у тебя нет прав на эту команду")
Answer the question
In order to leave comments, you need to log in
I managed to fix it like this:
def write_messages(sender, message):
authorize.method('messages.send', {'chat_id': sender, 'message': message, 'random_id': get_random_id(), 'attachment': ','.join(attachments)})
def write_messages_us(id, message):
authorize.method('messages.send', {'peer_id': id, 'message': message, 'random_id': get_random_id(), 'attachment': ','.join(attachments)})
elif re.findall('!Рассылка', reseived_message):
if event.object.message['from_id'] in admins:
for id in users:
try:
write_messages_us(id, (re.sub(r'!Рассылка', " ", reseived_message)))
except Exception as ex:
print("Ошибка")
else:
write_messages(sender, "У вас нет прав")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question