conv = event.obj.message['conversation_message_id']
per = event.object.message['from_id']
if event.from_user:
id = event.object.message['from_id']
if id == 'айди пользователя'
#Код
user = event.object.message['from_id']
admins = []
if user in admins:
#действия
checker = open('file_name', 'r')
shecker = checker.read()
checker.close()
user = event.object.message['from_id']
mes = event.object.message['text']
if mes == 'text' and user in shecker:
#действия
def adminadder(): #ADD
adder = open('file_name', 'a')
radder = adder.write(mes.split(' ')[1] + '\n')
adder.close()
pass
if mes.split(' ')[0] == 'adminadd':
adminadder()
def adminremover(): #REMOVE
rem = open('file_name', 'r')
lines = rem.readlines()
rem.close()
rem = open("administration.txt", "w")
for line in lines:
if line != mes.split(' ')[1] + "\n":
rem.write(line)
rem.close()
pass
if mes.split(' ')[0] == "adminremove':
adminremover()
import vk_api
token = ""
id_group = айди_группы
vk = vk_api.VkApi(token=token)
longpoll = VkBotLongPoll(vk, id_group)
getting_api = vk.get_api()
def otpravitel(id, message):
vk.method("messages.send", {"user_id": id, "message": text, 'random_id': 0})
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.from_user:
id = event.object.message['from_id']
mes = event.object.message['text']
if mes == 'Привет, как дела?'
otpravitel(id, 'Привет, отлично, у тебя?')
else:
otpravitel(id, 'Я не понял вас')
continue
def kicker(id):
vk.method("messages.removeChatUser", {'chat_id': id, 'user_id': mes.split(' ')[1]})
#Вызов
if mes.split(' ')[0] == 'кик':
mes = event.object.message['text']
id = event.chat_id
kicker(id)
#Функция бана
def ban(id, user_id):
vk.method("messages.removeChatUser", {'chat_id': id, 'user_id': user_id})
check = open('имя_файла', 'r')
recheck = check.read()
user_id = event.object.message['from_id']
if user_id in recheck :
ban(id, user_id)
def banagain(id, rinvite_id)
vk.method("messages.removeChatUser", {'chat_id': id, 'user_id': rinvite_id})
try:
rin = event.message.action['type']
rinvite_id = event.message.action['member_id']
except:
rinvite_id = -100
rin = ''
if rin == 'chat_invite_user':
if rinvite_id in recheck:
banagain(id, rinvite_id)
import vk_api, vk
from vk_api.keyboard import VkKeyboard, VkKeyboardColor
from vk_api.utils import get_random_id
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
vk = authorize.get_api()
authorize = vk_api.VkApi(token='ad6d1569fcd231ba7bb3af6d021144dc81a88d111111111111d5f0016a0ff5448c1ca33d649a2789b6975')
longpoll = VkBotLongPoll(authorize, group_id=206090038)
def take_name(from_id)
if from_id > 0:
sender_info = getting_api.users.get(user_ids=from_id)[0]
full_name = sender_info.get('first_name') + ' ' + sender_info['last_name']
return full_name
pass