random = random.randint(0,100000) #выдает случайное число с 0 до 100000
print('вота', random)
import time
get_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
def profilesender(id, text)
vk.method('messages.send', {'chat_id': id, 'message': text, 'random_id': 0})
def chatsender(id, text):
vk.method('messages.send', {'chat_id': id, 'message': text, 'random_id': 0})
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.from_chat:
user_id = event.object.message['from_id']
mes = event.object.message['text']
if mes == 'профиль':
vremya = '⏰Текущее время беседы:⏰\n' + str(time.asctime()) + '\n'
chat = event.chat_id + '\n' #можете указать ид вашего чата
user_name = get_name(from_id)
chatsender(id, 'Вот ваш профиль\n' + '@id' + user_id)
profilesender(id, 'Имя:' + user_name + '\n' + vremya + chat +)
event.object.message['from_id']
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 schedule
def primer():
#func options
schedule.every().day.at('8:00').do(primer)
while True:
schedule.run_pending()
time.sleep(3)
import threading
from threading import Thread
def thread2():
thr2 = Thread(target=primer)
thr2.start()
if __name__ == '__main__':
thread2()
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