Answer the question
In order to leave comments, you need to log in
I can't set up process 2 for chat, how to solve?
def adminchat should be a chat but doesn't work
import requests
from multiprocessing import Process
import vk_api
from vk_api import VkUpload
from vk_api.longpoll import VkLongPoll, VkEventType
from vk_api.utils import get_random_id
from random import *
def write_msg(user_id, message, random_id):
vk.method('messages.send', {'user_id': user_id, 'message': message,'random_id': random_id})
def write_msg2(user_id, message, random_id):
vkadmin.method('messages.send', {'user_id': user_id, 'message': message,'random_id': random_id})
def adminchat(adminchatid,adminchat_token):
vkadmin= vk_api.VkApi(token=adminchat_token)
longpoll = VkLongPoll(vkadmin)
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW and adminanswer==True:
if event.user_id=='мой_айди':
write_msg2(adminchatid,event.text,randint(-2147483648, 2147483647))
elif event.user_id==adminchatid:
write_msg2('мой_айди',event.text,randint(-2147483648, 2147483647))
elif event.user_id==adminchatid and event.text=='конец' or event.user_id=='мой_айди' and event.text=='конец':
write_msg2('мой_айди','Разговор окончен',randint(-2147483648, 2147483647))
write_msg2(adminchatid,'Разговор окончен',randint(-2147483648, 2147483647))
adminchatid=None
break
mangi=['ссылка']
chat_token = "токен"
adminchat_token = "токен"
vk = vk_api.VkApi(token=chat_token)
longpoll = VkLongPoll(vk)
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
request = event.text
a=event.text
str(a)
b="Вопрос";
print(b)
rid=event.random_id
if request == 'Что почитать' or request =='Рандомная манга' or request =='Рандом' or request =='рандом' or request =='что почитать' or request =='рандомная манга':
write_msg(event.user_id,'Хм, почитай вот это '+ mangi[randint(0,3)], randint(-2147483648, 2147483647))
elif request.find(b)>=0:
write_msg('мой_айди', "@id"+str(event.user_id)+" тебе написал, вот его текст <"+event.text+">", event.random_id)
write_msg(event.user_id, "Скоро я с вами свяжусь", randint(-2147483648, 2147483647))
adminchatid=event.user_id
newquestion=True
elif request == "Помощь":
write_msg(event.user_id, """Вот все команды бота:""", randint(-2147483648, 2147483647))
elif request=="12345ответ":
write_msg(event.user_id, "Запускается админ чат с ""@id"+str(adminchatid)+" ...", randint(-2147483648, 2147483647))
write_msg(adminchatid, "На ваш вопрос ответил админ, запуск чата", randint(-2147483648, 2147483647))
adminanswer=True
p=Process(target=adminchat,args=(adminchatid,adminchat_token))
p.start
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question