Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # !/usr/bin/env python
- # -*- coding: utf-8 -*-
- import sys
- import threading
- import vk_api
- from vk_api.longpoll import VkLongPoll, VkEventType
- from vk_api.keyboard import VkKeyboard, VkKeyboardColor
- from datetime import datetime
- import random
- import time
- import os
- import pymysql.cursors
- import logging
- import vkcoin
- file_log = logging.FileHandler('Log.log')
- console_out = logging.StreamHandler()
- merchant = vkcoin.VKCoinApi(user_id=242193778, ) # Ваш ID и ключ
- logging.basicConfig(handlers=(file_log, console_out),
- level=logging.INFO)
- logging.basicConfig(filename="sample.log", level=logging.INFO)
- """ БД """
- def connecti():
- conn = pymysql.connect(host='127.0.0.1',
- user='root',
- password='',
- db='vkbot',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- return conn
- def register(imid):
- connection = connecti()
- try:
- with connection.cursor() as cursor:
- result = cursor.execute(f"SELECT * FROM account WHERE idvk={imid}")
- row = cursor.fetchone()
- if result == 0:
- cursor.execute(f"INSERT INTO account(idvk) VALUES({imid})")
- connection.commit()
- else:
- return row
- finally:
- connection.close()
- def getdate (imid):
- connect = connecti()
- try:
- with connect.cursor() as cursor:
- result = cursor.execute(f"SELECT * FROM account WHERE idvk={imid}")
- row = cursor.fetchone()
- if result == 1:
- return row
- finally:
- connect.close()
- def savedate (imid, iq1, nickname1, job1, jobn1, timeend1, pazle1, paper1, excoins1, frac1, chees,doc,prog,sprog,atack,defend,regen,vs,vkcoin):
- connect = connecti()
- try:
- with connect.cursor() as cursor:
- result = cursor.execute(f"UPDATE account SET iq={iq1}, nickname='{nickname1}', job='{job1}', jobn={jobn1}, timeend={timeend1}, pazle={pazle1}, paper={paper1}, excoins={excoins1}, frac='{frac1}', chees={chees}, doc={doc}, prog = {prog}, sprog = {sprog}, atack = {atack}, defend = {defend}, regen = {regen}, vs={vs}, vkcoin={vkcoin} WHERE idvk={imid}")
- connect.commit()
- return result
- finally:
- connect.close()
- def savedatecoin (imid, vkcoin):
- connect = connecti()
- try:
- with connect.cursor() as cursor:
- result = cursor.execute(f"UPDATE account SET vkcoin={vkcoin} WHERE idvk={imid}")
- connect.commit()
- return result
- finally:
- connect.close()
- token = ""
- vk_session = vk_api.VkApi(token=token)
- session_api = vk_session.get_api()
- longpoll = VkLongPoll(vk_session)
- def captcha_handler(captcha):
- key = input("Enter captcha code {0}: ".format(captcha.get_url())).strip()
- return captcha.try_again(key)
- def create_keyboard(response):
- keyboard = VkKeyboard(one_time=True)
- keyboard.add_button('Я', color=VkKeyboardColor.NEGATIVE)
- keyboard.add_button('Работы', color=VkKeyboardColor.POSITIVE)
- # keyboard.add_button('Магазин', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Дела', color=VkKeyboardColor.DEFAULT)
- keyboard.add_button('Vkcoin', color=VkKeyboardColor.POSITIVE)
- keyboard.add_button('Битва', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Работать', color=VkKeyboardColor.DEFAULT)
- keyboard = keyboard.get_keyboard()
- return keyboard
- def noiq(imid, iqneed,iq):
- keyboard = create_rabota(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'У вас не достаточно {iqneed-iq} IQ, чтобы его прокачать, зайдите в пункт дела', 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- def create_rabota(response):
- keyboard = VkKeyboard(one_time=True)
- keyboard.add_button('Уборщик', color=VkKeyboardColor.POSITIVE)
- keyboard.add_button('Дворник', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Строитель', color=VkKeyboardColor.POSITIVE)
- keyboard.add_button('Архитектор', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Cпасатель', color=VkKeyboardColor.POSITIVE)
- keyboard.add_button('Юрист', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Дизайнер', color=VkKeyboardColor.POSITIVE)
- keyboard.add_button('Разработчик', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Я', color=VkKeyboardColor.NEGATIVE)
- keyboard = keyboard.get_keyboard()
- return keyboard
- def create_dela(response):
- keyboard = VkKeyboard(one_time=True)
- keyboard.add_button('Собирать пазлы', color=VkKeyboardColor.DEFAULT)
- keyboard.add_button('Читать газету', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Играть в шахматы', color=VkKeyboardColor.POSITIVE)
- keyboard.add_button('Читать техническую документацию', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Практиковаться в программировании', color=VkKeyboardColor.POSITIVE)
- keyboard.add_button('Написать высоконагруженный проект', color=VkKeyboardColor.POSITIVE)
- keyboard.add_line()
- keyboard.add_button('Я', color=VkKeyboardColor.NEGATIVE)
- keyboard = keyboard.get_keyboard()
- return keyboard
- def create_fractionkey(response):
- keyboard = VkKeyboard(one_time=True)
- keyboard.add_button('Фракция1', color=VkKeyboardColor.DEFAULT)
- keyboard.add_button('Фракция2', color=VkKeyboardColor.POSITIVE)
- keyboard = keyboard.get_keyboard()
- return keyboard
- def create_atackkey(response):
- keyboard = VkKeyboard(one_time=True)
- keyboard.add_button('Атака', color=VkKeyboardColor.NEGATIVE)
- keyboard.add_button('Защита', color=VkKeyboardColor.POSITIVE)
- keyboard = keyboard.get_keyboard()
- return keyboard
- def create_nz(response):
- keyboard = VkKeyboard(one_time=True)
- keyboard.add_button('Я', color=VkKeyboardColor.NEGATIVE)
- keyboard = keyboard.get_keyboard()
- return keyboard
- def create_vkcoinkey(response):
- keyboard = VkKeyboard(one_time=True)
- keyboard.add_button('Пополнить', color=VkKeyboardColor.NEGATIVE)
- keyboard = keyboard.get_keyboard()
- return keyboard
- """
- Поток и его поведение
- """
- def mesed (imid, responsce):
- row = register(imid)
- row = getdate(imid)
- job = row['job']
- iq = row['iq']
- nickname = row['nickname']
- excoins = row['excoins']
- timeend = row['timeend']
- jobn = row['jobn']
- pazle = row['pazle']
- paper = row['paper']
- frac = str(row['frac'])
- chees = row['chees']
- doc = row['doc']
- prog = row['prog']
- strongprog = row['sprog']
- atack = row['atack']
- defend = row['defend']
- regen = row['regen']
- vs = row['vs']
- vkcoin = row['vkcoin']
- if nickname == "":
- vk_session.method('messages.send', {'user_id': event.user_id, 'message': 'У вас не установлен ник, пожалуйста введите его :) ', 'random_id': random.randint(0, 9999999999), 'captcha_handler': captcha_handler})
- nickname = "*"
- elif nickname == "*":
- nickname = response
- keyboard = create_fractionkey(response)
- vk_session.method('messages.send',{'user_id': event.user_id, 'message': ' /*Ник установлен*/ Так же, тебе надо выбрать фракцию за которую ты будешь играть ', 'keyboard': keyboard,'random_id': random.randint(0, 9999999999), 'captcha_handler': captcha_handler})
- frac = "404"
- elif frac == "404":
- vk_session.method('messages.send', {'user_id': imid, 'message': "/*Фракция выбрана*/ \n О чём игра? \n Ты уже выбрал фракцию за которую ты будешь воевать, теперь именно они твои братья. \n Каждый день в 3 часа проходит битва в которой ты должен сражаться как атакующий или защищающий \n Чтобы увеличить урон или защиту, нужно купить предметы в магазине за excoins \n Чтобы заработать деньги нужно устроиться на работу, но не все работы будут доступны тебе сразу, для некоторых работ требуется равзитие тоесть очки IQ которые можно заработать в разделе Дела. \n Ну что-ж! Начнём. Для продолжения введите Я", 'random_id': random.randint(0, 9999999999), 'captcha_handler': captcha_handler})
- if response == "фракция1":
- frac = "фракция1"
- if response == "фракция2":
- frac = "фракция2"
- else:
- if response == "я":
- d1 = datetime.utcnow()
- d2 = datetime(d1.year,d1.month,d1.day,12)
- sc = round((d2-d1).total_seconds())
- mc = int(sc/60)
- hc = mc/60
- if mc - round(hc)*60 <= 0:
- timebitva = f"Завтра в 18:00"
- elif hc < 1:
- timebitva = f"через {mc} минут"
- elif hc >=1:
- timebitva = f"через {round(hc)} часов {mc - round(hc)*60} минут"
- keyboard = create_keyboard(response)
- messa = "🔎Я, " + str(nickname) + f"\n🚧Ваша фракция {frac}"
- messa = messa + "\n\n🔥Ваша работа: " + str(job) + " \n🧬Ваш IQ: " + str(iq) + "\n💰Ваш баланс: " + str(excoins) + f" excoins | {vkcoin} vkcoins"+f"\n\n 🧰Навыки: \n\n ⚔Атака:{atack} \n 🧯Защита:{defend} \n ⚒Регенерация:{regen} \n 🔋Выносливость:{vs} \n\n 🚨Битва {timebitva} \n 🚦Вы собрались"
- vk_session.method('messages.send', {'user_id': imid, 'message': messa, 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response =="vkcoin":
- keyboard = create_vkcoinkey(response)
- vk_session.method('messages.send', {'user_id': event.user_id,
- 'message': 'Меню действий с vkcoin',
- 'keyboard': keyboard, 'random_id': random.randint(0, 9999999999),
- 'captcha_handler': captcha_handler})
- elif response == "пополнить":
- keyboard = create_nz(response)
- result = merchant.get_payment_url(amount=10, payload=78922, free_amount=True)
- vk_session.method('messages.send', {'user_id': event.user_id,
- 'message': f'Вот ваша ссылка - {result} Сумму выбирайте сами.',
- 'keyboard': keyboard, 'random_id': random.randint(0, 9999999999),
- 'captcha_handler': captcha_handler})
- elif response == "битва":
- keyboard = create_atackkey(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'Это меню битвы, выберите будите вы атаковать или защищаться\n При атаке важен навыки ⚔Атака и 🔋Выносливость \n При Защите навыки ⚒Регенерация и 🧯Защита. \n Точный алгоритм битвы засекречен, но есть смысл и атаковать и защищаться. \n А теперь выбирите, будете вы защищться или атаковать', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response == "атака":
- statsb2 = "атаковать"
- keyboard = create_nz(response)
- vk_session.method('messages.send', {'user_id': event.user_id,
- 'message': 'Вы установили статус битвы, чтобы вернуться нажмите назад ',
- 'random_id': random.randint(0, 9999999999),
- 'captcha_handler': captcha_handler, 'keyboard': keyboard} )
- elif response == "защита":
- statsb2 = "защищять"
- keyboard = create_nz(response)
- vk_session.method('messages.send', {'user_id': event.user_id,
- 'message': 'Вы установили статус битвы, чтобы вернуться нажмите назад ',
- 'random_id': random.randint(0, 9999999999),
- 'captcha_handler': captcha_handler, 'keyboard': keyboard})
- elif response == "работы":
- keyboard = create_rabota(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': 'Работы: \n Название\iq необходимо\время\зарплата \nУборщик 0iq 1мин 1coin \nДворник 5iq 1.5 мин 3coin\nСтроитель 10iq 2мин 8сoin\nАрхитектор 30iq 2мин 10 coin\nСпасатель 50iq 2мин 20coin\nЮрист 100iq 3 мин 40coin\nДизайнер 120iq 4мин 50coin\nРазработчик 300iq 5мин 100coin', 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response == "уборщик":
- job = "уборщик"
- jobn = 1
- keyboard = create_keyboard(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response == "дворник":
- if iq>=5:
- job = "дворник"
- jobn = 2
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- noiq(imid,5,iq)
- elif response == "строитель":
- if iq >= 10:
- job = "строитель"
- jobn = 3
- keyboard = create_keyboard(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- noiq(imid,10,iq)
- elif response == "архитектор":
- if iq >= 30:
- job = "архитектор"
- jobn = 4
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- noiq(imid,30,iq)
- elif response == "спасатель":
- if iq >= 50:
- job = "спасатель"
- jobn = 5
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- noiq(imid,50,iq)
- elif response == "юрист":
- if iq >= 100:
- job = "юрист"
- jobn = 6
- keyboard = create_keyboard(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- noiq(imid,100,iq)
- elif response == "дизайнер":
- if iq >= 120:
- job = "дизайнер"
- jobn = 7
- keyboard = create_keyboard(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- noiq(imid,120,iq)
- elif response == "разработчик":
- if iq >= 300:
- job = "разработчик"
- jobn = 8
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Вы устроились на работу {job}', 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- noiq(imid,300,iq)
- elif response == "дела":
- keyboard = create_dela(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Дела нужны чтобы прокачать ваш IQ \n 1) Собрать пазлы Стоимость: {pazle} +0.1iq \n2) Читать газету Стоимость: {paper} +0.2 iq \n3) Играть в шахматы Стоимость:{chees} +0.5iq \n4) Читать техническую документацию Стоимость: {doc} + 1iq \n5) Практиковаться в программировании Стоимость: {prog} +3iq Только при iq>50 \n6) Написать высоконагруженный проект Стоимость: {strongprog} +10 iq Только при iq>150', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response == "собирать пазлы":
- if int(excoins) >= float(pazle):
- excoins = excoins - pazle
- pazle = pazle*1.5
- iq = iq+0.1
- keyboard = create_dela(response)
- vk_session.method('messages.send',
- {'user_id': imid, 'message': f'Вы собррпли пазлы для детей от 3-ёх лет. \n +0.1 IQ, теперь у вас {iq}',
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'У вас не хватает {pazle - excoins} денег', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response == "играть в шахматы":
- if int(excoins) >= float(chees):
- excoins = excoins - chees
- chees = chees * 1.5
- iq = iq + 0.5
- keyboard = create_dela(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Вы поиграли в шахматы, +0.5 IQ, теперь у вас {iq}',
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'У вас не хватает {chees - excoins} денег', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response == "читать газету":
- if int(excoins) >= float(paper):
- paper = excoins - paper
- paper = paper * 1.5
- iq = iq + 0.2
- keyboard = create_dela(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Вы прочитали газету, там было очень много жёлтых новостей, но попались и интерестные статьи \n +0.2 IQ, теперь у вас {iq}',
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'У вас не хватает 💰 {paper - excoins} excoins ', 'random_id': random.randint(0, 9999999999),'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif response == "читать техническую документацию":
- if int(excoins) >= float(doc):
- doc = excoins - doc
- paper = paper * 1.5
- iq = iq + 1
- keyboard = create_dela(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f'Вы прочитали техническую документацию, может быть, не до конца всё поняли, но определённая польза всё же была \n +1 IQ, теперь у вас {iq}',
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',
- {'user_id': imid, 'message': f'У вас не хватает 💰 {doc - excoins} excoins',
- 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,
- 'captcha_handler': captcha_handler})
- elif response == "практиковаться в программировании":
- if iq >= 50:
- if int(excoins) >= float(prog):
- excoins = excoins - doc
- doc = doc * 1.5
- iq = iq + 3
- keyboard = create_dela(response)
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f'Вы попрактиковались в программировании и написали не сложную программку \n +3 IQ, теперь у вас {iq}',
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'У вас не хватает 💰 {doc - excoins} excoins ',
- 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,
- 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',
- {'user_id': imid, 'message': f'Вы ещё не достаточно умны чтобы программировать нехваатет {50-iq}IQ',
- 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,
- 'captcha_handler': captcha_handler})
- elif response == "практиковаться в программировании":
- if iq >= 150:
- if int(excoins) >= float(sprog):
- excoins = excoins - sprog
- sprog = sprog * 1.5
- iq = iq + 7
- keyboard = create_dela(response)
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f'Вы попрактиковались в программировании и написали не сложную программу \n +7 IQ, теперь у вас {iq}',
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',{'user_id': imid, 'message': f'У вас не хватает {sprog - excoins} денег',
- 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,
- 'captcha_handler': captcha_handler})
- else:
- keyboard = create_dela(response)
- vk_session.method('messages.send',
- {'user_id': imid, 'message': f'Вы ещё не достаточно умны чтобы писать сложные программы нехваатет {150-iq}IQ',
- 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,
- 'captcha_handler': captcha_handler})
- elif response == "работать":
- gg = 0
- if timeend != 0:
- ep = datetime(1970,1,1,0,0,0)
- timegagh = (datetime.utcnow()- ep).total_seconds()
- gg = timegagh - timeend
- if jobn == 1:
- if gg >= 60 and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins)+1
- vk_session.method('messages.send', {'user_id': imid, 'message': "+1 excoin\nЧтобы вернуться нажмите Я", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < 60 and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(60 - gg)
- endf = int(endf)
- if endf / 60 < 1:
- mf = 0
- else:
- mf = endf / 60
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f"Вы еще не доработали, осталось {mf} минут {endf % 60} секунд",
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': "Вы начали работать уборщиком, это займет 1 минуту. \nВажно, чтобы получить зарплату через 1 или более минуту сного нажмите Работать", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- ep = datetime(1970,1,1,0,0,0)
- timeend = round((datetime.utcnow()- ep).total_seconds())
- elif jobn == 2:
- if gg >= 90 and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins)+5
- vk_session.method('messages.send', {'user_id': imid, 'message': "+3 excoin\nЧтобы вернуться нажмите Я", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < 90 and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(90 - gg)
- if endf/60 < 1:
- mf = 0
- else:
- mf = endf/60
- vk_session.method('messages.send', {'user_id': imid, 'message': f"Вы еще не доработали, осталось {mf} минут {endf%60} секунд" , 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f"Вы начали работать Дворником, это займет 1.5 минуты. \nВажно, чтобы получить зарплату через 1.5 или более минут ещё раз нажмите Работать", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- ep = datetime(1970,1,1,0,0,0)
- timeend = round((datetime.utcnow()- ep).total_seconds())
- elif jobn == 3:
- timek = 120
- if gg >= timek and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins)+8
- vk_session.method('messages.send', {'user_id': imid, 'message': "+5 excoin\nЧтобы вернуться нажмите Я", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < timek and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(timek - gg)
- if endf / 60 < 1:
- mf = 0
- else:
- mf = endf / 60
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f"Вы еще не доработали, осталось {mf} минут {endf % 60} секунд",
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f"Вы начали работать Строителем, это займет {timek/60} минут. \nВажно, чтобы получить зарплату через {timek/60} или более минут ещё раз нажмите Работать", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- ep = datetime(1970,1,1,0,0,0)
- timeend = round((datetime.utcnow()- ep).total_seconds())
- elif jobn == 4:
- timek = 120
- if gg >= timek and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins)+10
- vk_session.method('messages.send', {'user_id': imid, 'message': "+20 excoin\nЧтобы вернуться нажмите Я", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < timek and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(timek - gg)
- if endf / 60 < 1:
- mf = 0
- else:
- mf = endf / 60
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f"Вы еще не доработали, осталось {mf} минут {endf % 60} секунд",
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f"Вы начали работать Архитектором, это займет {timek/60} минут. \nВажно, чтобы получить зарплату через {timek/60} или более минут ещё раз нажмите Работать", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- ep = datetime(1970,1,1,0,0,0)
- timeend = round((datetime.utcnow()- ep).total_seconds())
- elif jobn == 5:
- timek = 120
- if gg >= timek and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins)+20
- vk_session.method('messages.send', {'user_id': imid, 'message': "+20 excoin\nЧтобы вернуться нажмите Я", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < timek and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(timek - gg)
- if endf / 60 < 1:
- mf = 0
- else:
- mf = endf / 60
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f"Вы еще не доработали, осталось {mf} минут {endf % 60} секунд",
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f"Вы начали работать Спасателем, это займет {timek/60} минут. \nВажно, чтобы получить зарплату через {timek/60} или более минут ещё раз нажмите Работать", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- ep = datetime(1970,1,1,0,0,0)
- timeend = round((datetime.utcnow()- ep).total_seconds())
- elif jobn == 6:
- timek = 180
- if gg >= timek and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins)+40
- vk_session.method('messages.send', {'user_id': imid, 'message': "+40 excoin\nЧтобы вернуться нажмите Я", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < timek and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(timek - gg)
- if endf / 60 < 1:
- mf = 0
- else:
- mf = endf / 60
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f"Вы еще не доработали, осталось {mf} минут {endf % 60} секунд",
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid, 'message': f"Вы начали работать Юристом, это займет {timek/60} минут. \nВажно, чтобы получить зарплату через {timek/60} или более минут ещё раз нажмите Работать", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- ep = datetime(1970,1,1,0,0,0)
- timeend = round((datetime.utcnow()- ep).total_seconds())
- elif jobn == 7:
- timek = 240
- if gg >= timek and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins) + 50
- vk_session.method('messages.send',{'user_id': imid, 'message': "+50 excoin\nЧтобы вернуться нажмите Я",'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < timek and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(timek - gg)
- if endf / 60 < 1:
- mf = 0
- else:
- mf = endf / 60
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f"Вы еще не доработали, осталось {mf} минут {endf % 60} секунд",
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid,'message': f"Вы начали работать Дизайнером, это займет {timek / 60} минут. \nВажно, чтобы получить зарплату через {timek / 60} или более минут ещё раз нажмите Работать", 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,'captcha_handler': captcha_handler})
- ep = datetime(1970, 1, 1, 0, 0, 0)
- timeend = round((datetime.utcnow() - ep).total_seconds())
- elif jobn == 8:
- timek = 300
- if gg >= timek and timeend != 0:
- keyboard = create_keyboard(response)
- excoins = int(excoins) + 100
- vk_session.method('messages.send',{'user_id': imid, 'message': "+50 excoin\nЧтобы вернуться нажмите Я",'random_id': random.randint(0, 9999999999), 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- timeend = 0
- elif gg < timek and timeend != 0:
- keyboard = create_keyboard(response)
- endf = round(timek - gg)
- if endf / 60 < 1:
- mf = 0
- else:
- mf = endf / 60
- vk_session.method('messages.send', {'user_id': imid,
- 'message': f"Вы еще не доработали, осталось {mf} минут {endf % 60} секунд",
- 'random_id': random.randint(0, 9999999999),
- 'keyboard': keyboard, 'captcha_handler': captcha_handler})
- elif timeend == 0:
- keyboard = create_keyboard(response)
- vk_session.method('messages.send', {'user_id': imid,'message': f"Вы начали работать Разработчиком, это займет {timek / 60} минут. \nВажно, чтобы получить зарплату через {timek / 60} или более минут ещё раз нажмите Работать",'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,'captcha_handler': captcha_handler})
- ep = datetime(1970, 1, 1, 0, 0, 0)
- timeend = round((datetime.utcnow() - ep).total_seconds())
- elif response == "назад":
- keyboard = create_keyboard(response)
- messa = "Я," + str(nickname)
- messa = messa + "\nВаша работа: " + str(job) + " \nВаш уровень: " + str(lvl) + " \nВаш IQ: " + str(iq) + "\nВаш баланс: " + str(excoins) + "excoins"
- vk_session.method('messages.send',{'user_id': imid, 'message': messa, 'random_id': random.randint(0, 9999999999), 'keyboard': keyboard,'captcha_handler': captcha_handler})
- savedate (imid, iq, nickname, job, jobn, timeend, pazle, paper, excoins, frac, chees,doc,prog,strongprog,atack,defend,regen,vs, vkcoin)
- """
- Основной цикл запуска потоков для пользователей
- """
- @merchant.lp_handler
- def payment_received(data):
- """
- При получении платежа будет запущена эта функция. Она может называться как угодно
- :param data.to_id: Ваш ID ВКонтакте
- :param data.id: ID платежа
- :param data.created_at: Unix timestamp, время когда был совершён платёж
- :param data.from_id: ID отправителя платежа
- :param data.amount: Количество полученных VK Coin
- """
- user_id = data.to_id
- amount = data.amount
- print('Получен платёж на сумму {amount} от {user_id}'.format(amount=amount, user_id=user_id))
- row = getdate(data.from_id)
- vkcoin = row['vkcoin']
- vkcoin = vkcoin + int(data.amount)/1000
- savedatecoin(data.from_id, vkcoin)
- def traz():
- while True:
- merchant.longpoll_start(tx=[1])
- while True:
- geg = threading.Thread(target = traz)
- geg.start()
- for event in longpoll.listen():
- if event.type == VkEventType.MESSAGE_NEW:
- print(f'<{str(datetime.strftime(datetime.now(), "%H:%M:%S"))}> ({str(event.user_id)}) -> {str(event.text)}')
- response = event.text.lower()
- if event.from_user and not event.from_me:
- idid = event.user_id
- t = threading.Thread(target = mesed,name = str(idid), args = (idid, response))
- t.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement