Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import time
- from os import listdir
- from random import choice
- import requests
- from teacher import *
- import vk_api
- from psutil import cpu_percent as usage_cpu
- from json import loads
- from random import randint
- spamfilter = []
- def getcpuu():
- return round(usage_cpu())
- def remove_signs(spams):
- spa = spams
- return list(set(spa))
- return spa
- def isAdmin(uid):
- amd = open('admins')
- admins = amd.read().split("\n")
- amd.close()
- return admins.count(str(uid)) >= 1
- def isUser(uid):
- f = open('users')
- dst = f.read().split()
- f.close()
- return dst.count(uid) >= 1
- def addmoney(uid, count):
- try:
- f = open('db/users/balance/{}.bot'.format(uid))
- except FileNotFoundError:
- create_newUser(uid)
- f = open('db/users/balance/{}.bot'.format(uid))
- bal = int(f.read())
- newbalance = bal + int(count)
- f.close()
- f = open('db/users/balance/{}.bot'.format(uid), 'w')
- f.write(str(newbalance))
- f.close()
- def create_newUser(uid):
- f = open('db/users/balance/{}.bot'.format(uid), 'w+')
- f.write('2000')
- f.close()
- return True
- def temp_encrypt(m):
- string = ""
- for i in m:
- string += chr(ord(i) ^ 399)
- return string
- def temp_decrypt(m):
- string = ""
- for i in m:
- string += chr(ord(i) ^ 399)
- return string
- def inFilter(family):
- f = open('filtres/filter.bot')
- vir = f.read().lower().split("\n").count(family) >= 1
- f.close()
- return vir
- def getsex(u):
- if u == 1:
- return 'она'
- elif u == 2:
- return 'он'
- else:
- return 'оно'
- def teach_bot(command, react):
- f = open('db/reaction/teacher.bot')
- def getbalance(uid):
- try:
- f = open('db/users/balance/{}.bot'.format(uid))
- except FileNotFoundError:
- create_newUser(uid)
- else:
- balance = f.read()
- f.close()
- return balance
- from os import system
- vk = vk_api.VkApi(login = input('login: '), password = input('password: '))
- vk.auth()
- check_auth(vk)
- values = {'out': 0,'count': 100,'time_offset': 60}
- def get_weather():
- pass
- def write_msg(user_id, s):
- global mid
- vk.method('messages.send', {'user_id':user_id,'message':s, 'forward_messages':mid})
- def write_msgg(gid, s):
- global mid
- vk.method('messages.send', {'chat_id':gid,'message':s, 'forward_messages':mid})
- def write_msggp(gid, s):
- a = vk.method('photos.getMessagesUploadServer')
- b = requests.post(a['upload_url'], files={'photo': open("pr/"+choice(listdir("pr")), 'rb')}).json()
- c = vk.method('photos.saveMessagesPhoto', {'photo': b['photo'], 'server': b['server'], 'hash': b['hash']})[0]
- d = 'photo{}_{}'.format(c['owner_id'], c['id'])
- vk.method('messages.send', {'chat_id': gid, 'attachment': d})
- while True:
- response = vk.method('messages.get', values)
- if response['items']:
- values['last_message_id'] = response['items'][0]['id']
- for item in response['items']:
- print(item)
- mid = item['id']
- amd = open('admins')
- admins = amd.read().split("\n")
- amd.close()
- if item['body'] == 'сасатб':
- print('[-] Bad message сасатб')
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Твоя работа')
- else:
- write_msg(item['user_id'], 'Твоя работа')
- elif item['body'].lower().split(' ')[0] == 'порнушка':
- print('[-] Bad message порнушка')
- if 'chat_id' in item:
- write_msggp(item['chat_id'], 'ДРАЧИТЬ')
- elif item['body'].lower() == 'admins':
- if 'chat_id' in item:
- adminlist = ""
- for ss in admins:
- adminlist += "[id"+ss+"|Он]\n"
- print('[~] User selector {}'.foramt('id'+str(ss)))
- write_msgg(item['chat_id'], adminlist)
- else:
- print('[~] Admin list')
- adminlist = ""
- for ss in admins:
- adminlist += "[id"+ss+"|Он]\n"
- write_msg(item['user_id'], adminlist)
- elif item['body'].lower().split(' ')[0] == 'addadmin':
- print('[_] Admin checking.... for uid {}'.format(item['user_id']))
- if isAdmin(item['user_id']):
- print('[~] Admin checked!')
- f = open('admins', 'a+')
- fss = open('admins')
- data = fss.read().split('\n').count(item['body'].split(' ')[1])
- fss.close()
- if data >= 1:
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'пользователь существует')
- continue
- else:
- write_msgg(item['chat_id'], 'пользователь существует')
- continue
- dds = "\n"+str(item['body'].split(' ')[1])
- f.write(dds)
- f.close()
- if 'chat_id' in item:
- print('[~] Adding admin!')
- write_msgg(item['chat_id'], 'Администратор добавлен')
- else:
- print('[~] Adding admin!')
- write_msg(item['user_id'], 'Администратор добавлен')
- else:
- print('[-] User not admin')
- if 'chat_id' in item:
- write_msgg(item['chat_id'], '[X] Ты не админ')
- else:
- write_msg(item['user_id'], '[X] Ты не админ')
- elif item['body'].lower() == 'загруженность':
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Загруженность - {}%'.format(getcpuu()))
- else:
- write_msg(item['user_id'], 'Загруженность - {}%'.format(getcpuu()))
- elif item['body'].split(" ")[0].lower() == 'кто':
- if 'chat_id' in item:
- if item['body'].lower().count("саня") >= 1:
- print('[-] Filter find admin name')
- write_msgg(item['chat_id'], 'тссс, админ тебя не слышит')
- continue
- elif item['body'].lower().count("sanya") >= 1 or item['body'].lower().count("саня") >= 1 or item['body'].lower().count("Саша") >= 1 or item['body'].lower().count("Александр") >= 1 or item['body'].lower().count("са-на") >= 1 or item['body'].lower().count("са-ня") >= 1 or item['body'].lower().count("с а н я") >= 1:
- print('[-] Filter find admin name')
- write_msgg(item['chat_id'], 'тссс, админ тебя не слышит')
- continue
- user = choice(vk.method("messages.getChat", {"chat_id":item['chat_id']})['users'])
- name = loads(requests.get("https://api.vk.com/method/users.get?user_id={}&fields=sex,first_name,last_name&v=5.52".format(user)).text)
- #print(name)
- if name['response'][0]['first_name'].lower()+" "+name['response'][0]['last_name'].lower() == 'саня федотов':
- print('[~] Replaceing admin name to Artyr Chernyu :D')
- name['response'][0]['first_name'] = 'Артур'
- name['response'][0]['last_name'] = 'Чёрный'
- user = 260415263;
- name['response'][0]['sex'] = 2
- print('[~] Random user selector')
- write_msgg(item['chat_id'], "Я думаю что это - [id{1}|{0}] {2}, да, точно {2}".format(name['response'][0]['first_name']+" "+name['response'][0]['last_name'], user, getsex(name['response'][0]['sex'])))
- else:
- print('[-] Group chat not defined')
- write_msg(item['user_id'], 'Это только в групповой беседе')
- elif item['body'].lower().split(' ')[0] == 'вероятность':
- spamfilter.append(item['user_id'])
- if inFilter(item['body']):
- print('[-] Filter find admin name')
- write_msgg(item['chat_id'], 'тссс, админ тебя не слышит')
- continue
- if spamfilter.count(item['user_id']) >= 5:
- print('[-] Spam filter required more id')
- spamfilter = remove_signs(spamfilter)
- time.sleep(1.4)
- continue
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Вероятность этого события равна - {}%'.format(randint(0, 100)))
- else:
- write_msg(item['user_id'], 'Вероятность этого события равна - {}%'.format(randint(0, 100)))
- elif item['body'].lower() == 'баланс':
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Ваш баланс - {} Рублей'.format(getbalance(item['user_id'])))
- else:
- write_msg(item['user_id'], 'Ваш баланс - {} Рублей'.format(getbalance(item['user_id'])))
- elif item['body'].lower().split(' ')[0] == 'ставка':
- if 'chat_id' in item:
- print('[~] Money price checking')
- if int(getbalance(item['user_id'])) <= 0:
- write_msgg(item['chat_id'], 'Ваш баланс равен нулю')
- print('[-] Balance equals 0')
- try:
- bal = int(item['body'].split(' ')[1])
- except IndexError:
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Введи ставку')
- continue
- else:
- write_msg(item['user_id'], 'Введи ставку')
- continue
- if False:
- pass
- elif int(getbalance(item['user_id'])) < int(item['body'].split(' ')[1]):
- print('[-] Balance not equals number stavka')
- write_msgg(item['chat_id'], 'Не достаточно денег')
- continue
- #except IndexError:
- #write_msgg(item['chat_id'], 'Ошибка введите ставку')
- #continue
- else:
- try:
- aww = int(item['body'].split(' ')[1])
- except:
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Выберите сумму ставки')
- print('[-] Stavka not selected')
- else:
- write_msg(item['user_id'], 'Выберите сумму ставки')
- print('[-] Stavka not selected')
- continue
- if randint(0, 2) == 1:
- try:
- award = randint(0, int(item['body'].split(' ')[1]) * 3)
- except:
- print('[-] number not selected')
- write_msgg('Введите число')
- continue
- write_msgg(item['chat_id'], 'Ваш выигрышь составил - {} Рублей'.format(award))
- print('[~] User {1} Win {0}'.format(award, item['user_id']))
- addmoney(item['user_id'], award)
- else:
- addmoney(item['user_id'], -1 * int(item['body'].split(' ')[1]))
- write_msgg(item['chat_id'], 'Упс, вы проиграли, ваш баланс - {} Рублей'.format(getbalance(item['user_id'])))
- print('[-] User {1} Lose'.format(item['user_id']))
- else:
- if getbalance(item['user_id']) <= 0:
- write_msgg('Ваш баланс равен нулю')
- print('[-] Balance equals 0')
- elif getbalance(item['user_id']) < int( item['body'].split(' ')[1]):
- write_msgg('Ваш баланс меньше чем сумма ставки')
- print('[-] Balance equals 0')
- else:
- if randint(0, 2) == 1:
- try:
- award = randint(0, item['body'].split(' ')[1] * 3)
- except:
- write_msgg('Введите число'.format(award))
- print('[-] Number not selected')
- continue
- write_msgg('Ваш выигрышь составил - {}'.format(award))
- addmoney(item['user_id'], award)
- else:
- addmoney(item['user_id'], -2 * int(item['body'].split(' ')[1]))
- write_msg(item['user_id'], 'Упс, вы проиграли, ваш баланс - {} Рублей'.format(getbalance(item['user_id'])))
- elif item['body'].lower().split(' ')[0] == 'add_money':
- if int(getbalance(item['user_id'])) <= 0:
- addmoney(item['user_id'], int(2000))
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Баланс пополнен, теперь он составляет - {}'.format(getbalance(item['user_id'])))
- else:
- write_msg(item['user_id'], 'Баланс пополнен, теперь он составляет - {}'.format(getbalance(item['user_id'])))
- else:
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'У вас не нулевой счёт')
- else:
- write_msg(item['user_id'], 'У вас не нулевой счёт')
- elif item['body'].lower() == 'рандом':
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Твоё рандомное число - {} 😎'.format(randint(0, 10000)))
- else:
- write_msg(item['user_id'], 'Твоё рандомное число - {} 😎'.format(randint(0, 10000)))
- elif item['body'].lower().split(' ')[0] == 'зашифровать':
- print('[~] Encrrypt message start')
- key = randint(0, 1000)
- #print('else')
- string = ""
- ccs = 0
- for i in item['body']:
- if ccs == 0:
- ccs += 1
- continue
- else:
- string += i+""
- crp = ""
- for i in string:
- crp += chr(ord(i) ^ key)
- crp = temp_encrypt(str(key))+":"+str(crp)
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Зашифрованное сообщение:\n{}'.format(crp))
- print('[~] Crypting message, crypted - {0}, decrypted - {1}'.format(crp, item['body'][10:]))
- else:
- write_msg(item['user_id'], 'Зашифрованное сообщение:\n{}'.format(crp))
- elif item['body'].lower().split(' ')[0] == 'дешифровать':
- print('[~] decrypt message stage')
- encstr = ""
- ccs = 0
- for i in item['body'].split(' '):
- if ccs == 0:
- ccs += 1
- continue
- encstr += i
- decstring = ""
- key = temp_decrypt(encstr.split(":")[0])
- realenc = encstr.split(":")[1]
- for i in realenc:
- decstring += chr(ord(i) ^ int(key))
- if 'chat_id' in item:
- try:
- write_msgg(item['chat_id'], 'Расшифрованно - {}'.format(decstring[10:]))
- except IndexError:
- write_msgg(item['chat_id'], 'Неправильный шифр')
- continue
- else:
- try:
- write_msg(item['user_id'], 'Расшифрованно - {}'.format(decstring[10:]))
- except IndexError:
- write_msgg(item['user_id'], 'Неправильный шифр')
- continue
- elif item['body'].lower().split(' ')[0] == 'скажи':
- if isAdmin(item['user_id']):
- arr = item['body'].split(' ')
- del arr[0]
- string = ""
- for i in arr:
- string += i+" "
- if 'chat_id' in item:
- write_msgg(item['chat_id'], string)
- else:
- write_msgg(item['user_id'], string)
- else:
- if 'chat_id' in item:
- write_msgg(item['chat_id'], '[X] Вы не админ')
- else:
- write_msgg(item['user_id'], '[X] Вы не админ')
- elif item['body'].split(' ')[0] == 'учи':
- print('teach')
- try:
- addreaction(item['body'].split('-;-')[0][3:], item['body'].split('-;-')[1])
- except IndexError:
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Не правильное заполнение')
- continue
- else:
- write_msg(item['user_id'], 'Не правильное заполнение')
- continue
- if 'chat_id' in item:
- write_msgg(item['chat_id'], 'Реакция добавлена')
- else:
- write_msg(item['user_id'], 'Реакция добавлена')
- elif item['body'].lower() == 'помощь':
- if 'chat_id' in item:
- write_msgg(item['chat_id'], '''
- Команды для бота:
- 1)Кто (Условие) - работает только в групповой беседе, выбирает случайного участника
- 2)Ставка (Сумма ставки) - Попытать удачу на рандоме
- 3)Рандом - случайное число от 0 до 10000
- 4)Зашифровать (что шифровать) - шифрует то что вы напишите
- 5)Дешифровать (что дешифровать) - дешифрует то зашифрованный текст
- 6)Скажи (что сказать) (Доступно только админам) скажет текст
- 7)admins - посмотреть админов
- 8)Вероятность (событие)- вычисляет вероятность в процентах события
- 9)баланс - узнать свой баланс
- ''')
- else:
- write_msg(item['user_id'], '''
- Команды для бота:
- 1)Кто (Условие) - работает только в групповой беседе, выбирает случайного участника
- 2)Ставка (Сумма ставки) - Попытать удачу на рандоме
- 3)Рандом - случайное число от 0 до 10000
- 4)Зашифровать (что шифровать) - шифрует то что вы напишите
- 5)Дешифровать (что дешифровать) - дешифрует то зашифрованный текст
- 6)Скажи (что сказать) (Доступно только админам) скажет текст
- 7)admins - посмотреть админов
- 8)Вероятность (событие)- вычисляет вероятность в процентах события
- 9)баланс - узнать свой баланс
- ''')
- else:
- while True:
- reactiond = get_reaction(item['body'])
- if reactiond.strip() != '':
- break
- if reactiond == '...':
- continue
- if 'chat_id' in item:
- write_msgg(item['chat_id'], reactiond)
- else:
- write_msg(item['user_id'], reactiond)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement