コード例 #1
0
async def repbrnch(ans: Message):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	blnc = cc.fetchall()[0][2]
	if ans.text.lower() == 'Назад'\
			or ans.text.lower() == 'назад':

		main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
					  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
					   {'text': '⬆', 'color': 'primary'}],
					  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

		main_kb = keyboard_gen(main_listb, one_time=False)
		await ans('...', keyboard=main_kb)
		return ExitBranch()

	else:

		main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
					  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
					   {'text': '⬆', 'color': 'primary'}],
					  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

		main_kb = keyboard_gen(main_listb, one_time=False)
		await ans('Репорт отправлен!\nОжидайте ответа от саппартов', keyboard=main_kb)
		user = await bot.api.users.get(user_ids=ans.from_id)
		user_n = user[0].first_name
		user_name = f'@id{ans.from_id} ({user_n})'
		await bot.api.messages.send(peer_id=2000000001, random_id=0,
									message=f'🆘Report🆘\nОт {user_name}\nID VK: {ans.from_id}\nТекст репорта:\n{ans.text.lower()}'
									)
		return ExitBranch()
コード例 #2
0
    async def day_schedule(self, ans: Message):

        payload = ujson.loads(ans.payload)

        u = await UserState.get(uid=ans.from_id)

        if isinstance(u.context, str):
            u.context = ujson.loads(u.context)

        u_weekday = u.context['weekday']

        if payload['day'] == 'next':
            u_weekday = (u_weekday + 1) % 7
        else:
            u_weekday = (u_weekday - 1) % 7

        schedule = await cache.get('schedule_{}'.format(str(ans.from_id)))
        if schedule is None:
            data = await fetch_schedule_json(q=u.context['query'])
            schedule = ScheduleResponseBuilder(data)
            await cache.set('schedule_{}'.format(str(ans.from_id)),
                            schedule,
                            ttl=900)

        schedule.build_text(weekday=u_weekday)

        msg = schedule.get_text()

        await ans(message=msg,
                  keyboard=keyboard_gen(SCHEDULE_KEYBOARD, one_time=False))

        u.context['weekday'] = u_weekday
        await u.save()
コード例 #3
0
ファイル: bot.py プロジェクト: ketsucode/vkbottle-example-bot
async def wrapper(ans: Message):
    await ans("1 message")
    await ans("2 message")
    await ans("3 message")
    await ans(
        "4 message", keyboard=keyboard_gen([[{"text": "test"}]], one_time=True)
    )  # test keyboard
コード例 #4
0
async def autoreg(ans: Message):
	if ans.peer_id < 2e9:
		cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
		result = cc.fetchall()

		if len(result) >= 1:
			pass

		else:
			cc.execute(f"SELECT * FROM global")
			gresult = cc.fetchall()
			pid = gresult[0][0]
			pid += 1
			cc.execute("INSERT INTO users (vkid, pid, blnc, bant)"
					   f"VALUES ('{ans.from_id}', '{pid}', '100', '0')"
					   )
			cc.execute(f"UPDATE global SET allusers = {pid}")
			connection.commit()

			main_listb = [[{'text': f'Баланс: 100', 'color': 'secondary'}],
						  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
						   {'text': '⬆', 'color': 'primary'}],
						  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

			main_kb = keyboard_gen(main_listb, one_time=False)
			await ans('Добро пожаловать в VCuti!\nЭто бот для игры в Nvuti на VKCoins💲\nОзнакомься с👇\n'
					  'Условия использования -  📃\n'
					  'Как пользоваться клавиатурой бота -  ℹ', keyboard=main_kb)

			with open("rlist.txt", "r", encoding="UTF-8") as f:
				peers = list(ast.literal_eval(f.read()))
			list.append(peers, ans.from_id)
			with open("rlist.txt", "w") as f:
				f.write(f"{peers}")
コード例 #5
0
    async def get_day_schedule(self, ans: Message):

        payload = ujson.loads(ans.payload)
        weekday = int(payload['day_num'])

        u = await UserState.get(uid=ans.from_id)

        if isinstance(u.context, str):
            u.context = ujson.loads(u.context)

        caches.set_config(CACHE_CONFIG)

        schedule = await cache.get('schedule_{}'.format(str(ans.from_id)))
        if schedule is None:
            data = await fetch_schedule_json(q=u.context['query'])
            schedule = ScheduleResponseBuilder(data)
            await cache.set('schedule_{}'.format(str(ans.from_id)),
                            schedule,
                            ttl=900)

        schedule.build_text(weekday=weekday)
        msg = schedule.get_text()

        await ans(message=msg,
                  keyboard=keyboard_gen(SCHEDULE_KEYBOARD, one_time=False))

        u.context['weekday'] = weekday
        await u.save()
コード例 #6
0
 async def exit_branch(self, ans: Message):
     await ans(
         message='За дополнительной информацией вы всегда можете обратиться к наставникам '
                 'или на сайт Проектного офиса',
         keyboard=keyboard_gen(EMPTY_KEYBOARD, one_time=False)
     )
     await return_to_main_menu(ans)
コード例 #7
0
    async def branch(self, ans: Message):
        q = ans.text

        u = await UserState.get(uid=ans.from_id)

        if isinstance(u.context, str):
            u.context = ujson.loads(u.context)

        weekday = datetime.today().weekday() + 1

        try:
            data = await fetch_schedule_json(q)
            schedule = ScheduleResponseBuilder(data)
        except aiohttp.ClientResponseError:
            await ans(
                'Произошла ошибка, возможно API расписания временно не работает. '
                'Если это продолжается длительное время, обратитесь к администрации сайта.'
            )
        except ScheduleNoEntriesFoundException:
            await ans('Извините, по вашему запросу ничего не найдено.',
                      keyboard=keyboard_gen(EMPTY_KEYBOARD))
        except ScheduleUnknownErrorException:
            await ans(
                message='Произошла неизвестная ошибка при обработке расписания. '
                'Обратитесь к администрации за дополнительной информацией.',
                keyboard=keyboard_gen(EMPTY_KEYBOARD))
        except ScheduleMultipleChoicesException:
            msg, keyboard = parse_choices(data)

            await ans(message=msg, keyboard=keyboard_gen(keyboard))
        else:
            schedule.build_text(weekday)
            msg = schedule.get_text()

            u.context['weekday'] = weekday
            u.context['week'] = schedule.week
            u.context['query'] = q

            await cache.set('schedule_{}'.format(str(ans.from_id)),
                            schedule,
                            ttl=900)

            await u.save()

            await ans(message=msg,
                      keyboard=keyboard_gen(SCHEDULE_KEYBOARD, one_time=True))
コード例 #8
0
def create_keyboard(*rows, one_time=False):
    keyboard = keyboard_gen(
        [[{
            "text": button["text"],
            "color": button["color"] if "color" in button else "primary",
            "payload": button["payload"] if "payload" in button else "",
            "type": button["type"] if "type" in button else "text"
        } for button in row] for row in rows],
        one_time=one_time)
    return keyboard
コード例 #9
0
async def pblnc(ans: Message):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	blnc = cc.fetchall()[0][2]

	main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
				  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
				   {'text': '⬆', 'color': 'primary'}],
				  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

	main_kb = keyboard_gen(main_listb, one_time=False)
	await ans('Для оплаты перейдите\n\nКоммисия 5%', keyboard=main_kb) # Укажите вашу ссылку для оплаты!!!
コード例 #10
0
async def strt(ans: Message):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	blnc = cc.fetchall()[0][2]

	main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
				  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
				   {'text': '⬆', 'color': 'primary'}],
				  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

	main_kb = keyboard_gen(main_listb, one_time=False)
	await ans('...', keyboard=main_kb)
コード例 #11
0
    async def change_week(self, ans: Message):
        payload = ujson.loads(ans.payload)

        u = await UserState.get(uid=ans.from_id)

        if isinstance(u.context, str):
            u.context = ujson.loads(u.context)

        _u_week = u.context['week']
        _query = u.context['query']

        if payload['week'] == 'next':
            _u_week += 1
        else:
            _u_week -= 1

        try:
            data = await fetch_schedule_json(_query, week=_u_week)
            schedule = ScheduleResponseBuilder(data)
            schedule.build_text(weekday=1)
        except aiohttp.ClientResponseError:
            await ans(
                'При обработке запроса произошла ошибка, возможно API расписания временно не работает. '
                'Если это продолжается длительное время, обратитесь к администрации сайта.'
            )
        except ScheduleUnknownErrorException:
            await ans(
                message=
                'Произошла неизвестная ошибка при обработке расписания. Обратитесь к администрации сайта за дополнительной информацией.',
                keyboard=keyboard_gen(EMPTY_KEYBOARD))
        else:
            msg = schedule.get_text()
            await ans(message=msg,
                      keyboard=keyboard_gen(SCHEDULE_KEYBOARD, one_time=False))

            await cache.set('schedule_{}'.format(str(ans.from_id)),
                            schedule,
                            ttl=900)

            u.context['week'] = _u_week
            await u.save()
コード例 #12
0
async def dnb(ans: Message, arg):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	result = cc.fetchall()
	blnc = result[0][2]

	main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
				  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
				   {'text': '⬆', 'color': 'primary'}],
				  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

	main_kb = keyboard_gen(main_listb, one_time=False)
	await ans(f'Это ваш баланс\nОн равен {arg}', keyboard=main_kb)
コード例 #13
0
async def play_inst(ans: Message):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	blnc = cc.fetchall()[0][2]

	main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
				  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
				   {'text': '⬆', 'color': 'primary'}],
				  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

	main_kb = keyboard_gen(main_listb, one_time=False)
	await ans(
		'Чтобы играть используйте следующую команду👇🏻\nНвути процент меньше(1), больше(2) сумма ставки\n'
		'Пример: Нвути 70 1 100', keyboard=main_kb)
コード例 #14
0
async def nfa(ans: Message, arg):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	result = cc.fetchall()
	blnc = result[0][2]

	main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
				  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
				   {'text': '⬆', 'color': 'primary'}],
				  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

	main_kb = keyboard_gen(main_listb, one_time=False)
	await ans(f'"{arg}", что это такое?🧐 Не понимаю тебя!🙁\nИспользуй клавиатуру и вводи команды верно💭',
			  keyboard=main_kb)
コード例 #15
0
ファイル: utils.py プロジェクト: iryabuhin/proictis_bot_v2
async def return_to_main_menu(message: Message, context: Dict[str, str] = None) -> None:
    u = await UserState.get_or_none(uid=message.from_id)
    u.branch = 'main'

    if context is not None:
        u.context.update(
            **context
        )

    await u.save()
    await message(
        message='Главное меню',
        keyboard=keyboard_gen(MAIN_MENU_KEYBOARD)
    )
コード例 #16
0
async def mrezerv(ans: Message):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	blnc = cc.fetchall()[0][2]
	rzrv = merchant.get_balance(520369348, 520369348)
	rzrv = rzrv['520369348']
	rzrv /= 1000

	main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
				  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
				   {'text': '⬆', 'color': 'primary'}],
				  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

	main_kb = keyboard_gen(main_listb, one_time=False)
	await ans(f'🗄Резерв бота - {rzrv}🗄', keyboard=main_kb)
コード例 #17
0
 async def branch(self, ans: Message, *args):
     try:
         query_result = detect_intent_texts(
             Config.PROJECT_ID,
             ans.from_id,
             ans.text,
             'ru-RU'
         )
     # TODO add logging
     except GoogleAPIError as e:
         raise GoogleAPIError(e)
     except ValueError as e:
         raise ValueError(e)
     else:
         msg = query_result.get('fulfillmentText')
         await ans(msg, keyboard=keyboard_gen([[EXIT_BUTTON]], one_time=False))
コード例 #18
0
    async def show_weekdays(self, ans: Message):

        caches.set_config(CACHE_CONFIG)

        schedule = await cache.get('schedule_{}'.format(ans.from_id))

        if schedule is None:
            data = await fetch_schedule_json()
            schedule = ScheduleResponseBuilder(data)
            await cache.set('schedule_{}'.format(ans.from_id),
                            schedule,
                            ttl=900)

        schedule.build_weekday_keyboard()
        keyboard = schedule.get_keyboard()

        await ans(message='Выберите день недели:',
                  keyboard=keyboard_gen(keyboard))
コード例 #19
0
ファイル: longpoll_bot.py プロジェクト: lujo777/vkbottle-1
async def wrapper(ans: Message):
    keyboard = [[{'text': 'fantastic button'}]]
    await ans('hi, my lil friend', keyboard=keyboard_gen(keyboard))
コード例 #20
0
"""SETTINGS"""
owner_vkid = 0 # Your VKID
merchant = vkcoin.VKCoin(user_id=owner_vkid, # Ваш ID на котором есть VKCoins
						 key='') # Ключ апи VKCoins

connection = sql.connect("vcuti_datab.db")
cc = connection.cursor()

"""KEYBOARDS"""
pvk_list = [[{'text': '100000', 'color': 'secondary'}, {'text': '500000', 'color': 'secondary'},
			 {'text': '1000000', 'color': 'secondary'}],
			[{'text': '2000000', 'color': 'primary'}, {'text': '5000000', 'color': 'primary'}],
			[{'text': '10000000', 'color': 'positive'}, {'text': '50000000', 'color': 'positive'}],
			[{'text': 'Назад', 'color': 'negative'}]]
pvk_kb = keyboard_gen(pvk_list, one_time=True)

nzd_list = [[{'text': 'Назад', 'color': 'negative'}]]
nzd_kb = keyboard_gen(nzd_list, one_time=True)

"""LONGPOLL"""
bot = Bot('',  # Твой токен group_id, НЕЗАБУДЬ включить Longpoll
		  group_id=,
		  debug=True)


@bot.on.pre_process()  # registration
async def autoreg(ans: Message):
	if ans.peer_id < 2e9:
		cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
		result = cc.fetchall()
コード例 #21
0
async def play_nvuti(ans: Message, prc, b_or_m, sst):						   # При желании можно исправить на более сложный вариант с классами и т.д.
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	result = cc.fetchall()
	blnc = result[0][2]
	aablnc = blnc + 1
	prcc = 10000
	prcc *= prc

	cc.execute("SELECT * FROM global")
	lpdk = cc.fetchall()[0][2]
	t1o4 = random.randint(1, lpdk)
	prc = round(prc, 2)
	sst = round(sst, 2)

	if prc <= 95.0:

		if prc >= 1.0:

			if sst >= float(aablnc):
				main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
							  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
							   {'text': '⬆', 'color': 'primary'}],
							  [{'text': '🗄Резерв🗄', 'color': 'negative'},
							   {'text': '🆘Репорт🆘', 'color': 'negative'}]]

				main_kb = keyboard_gen(main_listb, one_time=False)
				await ans('Недостаточно средств на балансе!', keyboard=main_kb)

			elif t1o4 == 1:  # подкрутка
				if b_or_m == 1:  # меньше подкрутка
					pcount = random.randint(prcc, 999999)
					blnc -= sst
					blnc = round(blnc, 2)
					cc.execute(f"UPDATE users SET blnc = {blnc} WHERE vkid = {ans.from_id}")
					connection.commit()

					nvuti_listb = [[{'text': f'Нвути {prc} {b_or_m} {sst}', 'color': 'negative'}],
								   [{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
								   [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
									{'text': '⬆', 'color': 'primary'}],
								   [{'text': '🗄Резерв🗄', 'color': 'negative'},
									{'text': '🆘Репорт🆘', 'color': 'negative'}]]

					nvuti_kb = keyboard_gen(nvuti_listb, one_time=False)
					await ans(f'Сожалею! Вы проиграли😭\nВаш баланс - {blnc}💰\nВыпало число - {pcount}🎲',
							  keyboard=nvuti_kb)

				elif b_or_m == 2:  # больше подкрутка
					pcount = random.randint(0, prcc)
					blnc -= sst
					blnc = round(blnc, 2)
					cc.execute(f"UPDATE users SET blnc = {blnc} WHERE vkid = {ans.from_id}")
					connection.commit()

					nvuti_listb = [[{'text': f'Нвути {prc} {b_or_m} {sst}', 'color': 'negative'}],
								   [{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
								   [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
									{'text': '⬆', 'color': 'primary'}],
								   [{'text': '🗄Резерв🗄', 'color': 'negative'},
									{'text': '🆘Репорт🆘', 'color': 'negative'}]]

					nvuti_kb = keyboard_gen(nvuti_listb, one_time=False)
					await ans(f'Сожалею! Вы проиграли😭\nВаш баланс - {blnc}💰\nВыпало число - {pcount}🎲',
							  keyboard=nvuti_kb)

				else:
					main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
								  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
								   {'text': '⬆', 'color': 'primary'}],
								  [{'text': '🗄Резерв🗄', 'color': 'negative'},
								   {'text': '🆘Репорт🆘', 'color': 'negative'}]]

					main_kb = keyboard_gen(main_listb, one_time=False)
					await ans('Ошибка!❌\nКажется вы неправильно установили значение меньше(1) или больше(2)❗',
							  keyboard=main_kb)
			else:  # неподкрутка
				pcount = random.randint(0, 999999)
				if b_or_m == 1:  # меньше

					if pcount <= prcc:
						osst = sst / prc
						osst *= 100
						osst -= sst
						blnc += osst
						blnc = round(blnc, 2)
						cc.execute(f"UPDATE users SET blnc = {blnc} WHERE vkid = {ans.from_id}")
						connection.commit()

						nvuti_listb = [[{'text': f'Нвути {prc} {b_or_m} {sst}', 'color': 'positive'}],
									   [{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
									   [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
										{'text': '⬆', 'color': 'primary'}],
									   [{'text': '🗄Резерв🗄', 'color': 'negative'},
										{'text': '🆘Репорт🆘', 'color': 'negative'}]]

						nvuti_kb = keyboard_gen(nvuti_listb, one_time=False)
						await ans(f'Поздравляю! Вы выиграли🎉\nВаш баланс - {blnc}💰\nВыпало число - {pcount}🎲',
								  keyboard=nvuti_kb)

					elif pcount >= prcc:
						blnc -= sst
						blnc = round(blnc, 2)
						cc.execute(f"UPDATE users SET blnc = {blnc} WHERE vkid = {ans.from_id}")
						connection.commit()

						nvuti_listb = [[{'text': f'Нвути {prc} {b_or_m} {sst}', 'color': 'negative'}],
									   [{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
									   [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
										{'text': '⬆', 'color': 'primary'}],
									   [{'text': '🗄Резерв🗄', 'color': 'negative'},
										{'text': '🆘Репорт🆘', 'color': 'negative'}]]

						nvuti_kb = keyboard_gen(nvuti_listb, one_time=False)
						await ans(f'Сожалею! Вы проиграли😭\nВаш баланс - {blnc}💰\nВыпало число - {pcount}🎲',
								  keyboard=nvuti_kb)

					else:
						main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
									  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
									   {'text': '⬆', 'color': 'primary'}],
									  [{'text': '🗄Резерв🗄', 'color': 'negative'},
									   {'text': '🆘Репорт🆘', 'color': 'negative'}]]
						main_kb = keyboard_gen(main_listb, one_time=False)
						await ans(
							'Техническая ошибка❌\nПожалуйста скопируйте это сообщение и отправьте в репорт с пометкой #баг\nКод ошибки: Число не совпадает с условиями',
							keyboard=main_kb)

				elif b_or_m == 2:
					prcc = 999999 - prcc
					if pcount >= prcc:
						osst = sst / prc
						osst *= 100
						osst -= sst
						blnc += osst
						blnc = round(blnc, 2)
						cc.execute(f"UPDATE users SET blnc = {blnc} WHERE vkid = {ans.from_id}")
						connection.commit()

						nvuti_listb = [[{'text': f'Нвути {prc} {b_or_m} {sst}', 'color': 'positive'}],
									   [{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
									   [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
										{'text': '⬆', 'color': 'primary'}],
									   [{'text': '🗄Резерв🗄', 'color': 'negative'},
										{'text': '🆘Репорт🆘', 'color': 'negative'}]]

						nvuti_kb = keyboard_gen(nvuti_listb, one_time=False)
						await ans(f'Поздравляю! Вы выиграли🎉\nВаш баланс - {blnc}💰\nВыпало число - {pcount}🎲',
								  keyboard=nvuti_kb)

					elif pcount <= prcc:
						blnc -= sst
						blnc = round(blnc, 2)
						cc.execute(f"UPDATE users SET blnc = {blnc} WHERE vkid = {ans.from_id}")
						connection.commit()

						nvuti_listb = [[{'text': f'Нвути {prc} {b_or_m} {sst}', 'color': 'negative'}],
									   [{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
									   [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
										{'text': '⬆', 'color': 'primary'}],
									   [{'text': '🗄Резерв🗄', 'color': 'negative'},
										{'text': '🆘Репорт🆘', 'color': 'negative'}]]

						nvuti_kb = keyboard_gen(nvuti_listb, one_time=False)
						await ans(f'Сожалею! Вы проиграли😭\nВаш баланс - {blnc}💰\nВыпало число - {pcount}🎲',
								  keyboard=nvuti_kb)

					else:
						await ans(
							'Техническая ошибка❌\nПожалуйста скопируйте это сообщение и отправьте в репорт с пометкой #баг\nКод ошибки: Число не совпадает с условиями')
				else:
					main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
								  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
								   {'text': '⬆', 'color': 'primary'}],
								  [{'text': '🗄Резерв🗄', 'color': 'negative'},
								   {'text': '🆘Репорт🆘', 'color': 'negative'}]]

					main_kb = keyboard_gen(main_listb, one_time=False)
					await ans('Ошибка!❌\nКажется вы неправильно установили значение меньше(1) или больше(2)❗',
							  keyboard=main_kb)
		else:
			main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
						  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
						   {'text': '⬆', 'color': 'primary'}],
						  [{'text': '🗄Резерв🗄', 'color': 'negative'},
						   {'text': '🆘Репорт🆘', 'color': 'negative'}]]
			main_kb = keyboard_gen(main_listb, one_time=False)
			await ans('Ошибка!❌\nКажется вы неправильно установили процент (от 1 до 95)❗', keyboard=main_kb)
	else:

		main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
					  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
					   {'text': '⬆', 'color': 'primary'}],
					  [{'text': '🗄Резерв🗄', 'color': 'negative'},
					   {'text': '🆘Репорт🆘', 'color': 'negative'}]]

		main_kb = keyboard_gen(main_listb, one_time=False)
		await ans('Ошибка!❌\nКажется вы неправильно установили процент (от 1 до 95)❗', keyboard=main_kb)
コード例 #22
0
async def vbranch(ans: Message):
	cc.execute(f"SELECT * FROM users WHERE vkid = {ans.from_id}")
	blnc = cc.fetchall()[0][2]
	cc.execute(f"SELECT * FROM global")
	ccm = cc.fetchall()[0][1]
	if ans.text.lower() == 'Назад':
		main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
					  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
					   {'text': '⬆', 'color': 'primary'}],
					  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]

		main_kb = keyboard_gen(main_listb, one_time=False)
		await ans('...', keyboard=main_kb)
		return ExitBranch()

	else:

		try:
			sum = int(ans.text.lower())
			if sum <= blnc:
				ccm += sum * 0.05
				amount = sum - sum * 0.05
				amount *= 1000
				merchant.send_payment(ans.from_id, amount)
				blnc -= sum
				blnc = round(blnc, 2)
				cc.execute(f"UPDATE users SET blnc = {blnc} WHERE vkid = {ans.from_id}")
				cc.execute(f"UPDATE global SET comcoins = {ccm}")
				connection.commit()

				main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
							  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
							   {'text': '⬆', 'color': 'primary'}],
							  [{'text': '🗄Резерв🗄', 'color': 'negative'},
							   {'text': '🆘Репорт🆘', 'color': 'negative'}]]

				main_kb = keyboard_gen(main_listb, one_time=False)
				await ans('Готово✔️', keyboard=main_kb)
				return ExitBranch()

			else:
				main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
							  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
							   {'text': '⬆', 'color': 'primary'}],
							  {{'text': '🗄Резерв🗄', 'color': 'negative'},
							   {'text': '🆘Репорт🆘', 'color': 'negative'}}]

				main_kb = keyboard_gen(main_listb, one_time=False)
				await ans('Недостаточно средств на балансе❌', keyboard=main_kb)
				return ExitBranch()

		except Exception as e:
			print(f'{e}')
			main_listb = [[{'text': f'Баланс: {blnc}', 'color': 'secondary'}],
						  [{'text': '⬇', 'color': 'primary'}, {'text': 'Играть▶', 'color': 'negative'},
						   {'text': '⬆', 'color': 'primary'}
						   ],
						  [{'text': '🗄Резерв🗄', 'color': 'negative'}, {'text': '🆘Репорт🆘', 'color': 'negative'}]]
			main_kb = keyboard_gen(main_listb, one_time=False)
			await ans('...', keyboard=main_kb)
			return ExitBranch()
コード例 #23
0
async def faq_wrapper(ans: Message):
    await ans('Задавайте вопросы и мы попытаемся найти на них ответ!',
              keyboard=keyboard_gen([[EXIT_BUTTON]])
              )
    await bp.branch.add(ans.from_id, 'faq')
コード例 #24
0
async def wrapper(ans: Message):
    await ans('Heres your keyboard', keyboard=keyboard_gen(MAIN_MENU_KEYBOARD))
コード例 #25
0
ファイル: templates.py プロジェクト: yilbegan/vkbottle
from vkbottle import Bot, Message
from vkbottle import carousel_gen, CarouselEl, keyboard_gen
import os

# Add variable TOKEN to your env variables
bot = Bot(os.environ["TOKEN"])

template = carousel_gen(
    CarouselEl(photo_id="-109837093_457242809",
               buttons=keyboard_gen([[{
                   "text": "баттон 1"
               }]]),
               action={"type": "open_photo"}),
    CarouselEl(photo_id="-109837093_457242809",
               buttons=keyboard_gen([[{
                   "text": "баттон 2"
               }]]),
               action={"type": "open_photo"}),
)


@bot.on.message_handler(text="хочу темплейт", lower=True)
async def consignment(ans: Message):
    await ans(ans.dict())
    await ans("Держи темплейт!", template=template)


bot.run_polling()