-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
91 lines (76 loc) · 3.44 KB
/
main.py
File metadata and controls
91 lines (76 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import telebot
import logging
import random
logging.basicConfig(format=u'%(filename)s[LINE:%(lineno)-3s]# %(levelname)-5s [%(asctime)s] %(message)s'
, level=logging.INFO)
bot = telebot.TeleBot("447246469:AAETslLMelxZhW-nbpOTLRJQY0m2D-1fCjA")
def niceprint(string):
tabindex = 0
out = ''
for i in string:
if i == ',':
out += i
out += '\n'
out += '\t' * tabindex
continue
if i == '{':
tabindex += 1
if i == '}':
tabindex -= 1
out += '\n'
out += i
return out
a = []
keyboard = telebot.types.InlineKeyboardMarkup()
keyboard.row(telebot.types.InlineKeyboardButton('Зарегистрироваться', callback_data='reg'))
keyboard.row(telebot.types.InlineKeyboardButton('Выдать калик', callback_data='chooser'))
@bot.callback_query_handler(func=lambda call: call.data == 'reg')
def reg(call):
# bot.send_message(call.message.chat.id, 'Жопа')
if call.from_user.username in a:
bot.answer_callback_query(call.id, text='Ты уже зареган!')
else:
a.append(call.from_user.username)
print(a)
out = '''Кто же будет первым курить *калик*?
Зарегистрируйся потом жми "Выдать калик".\n\nУчастники:'''
for i in a:
out += '\n' + '- ' + str(i)
bot.edit_message_text(out, call.message.chat.id, call.message.message_id, reply_markup=keyboard
, parse_mode='Markdown')
@bot.callback_query_handler(func=lambda call: call.data == 'chooser')
def chooser(call):
global a
if len(a) == 0:
bot.answer_callback_query(call.id, 'Нужны люди')
if len(a) == 1:
bot.answer_callback_query(call.id, 'Нужно больше 1 человека')
# out = '''Кто же будет первым курить *калик*?
# Зарегистрируйся потом жми "Выдать калик".\n\n'''
# logging.info(a)
# for indx, i in enumerate(a):
# out += '\n' + str(indx + 1) + '. ' + str(i)
# out += '\n\nНужно больше участников'
# bot.edit_message_text(out, call.message.chat.id, call.message.message_id, reply_markup=keyboard
# , parse_mode='Markdown')
if len(a) > 1:
logging.info(a)
random.shuffle(a)
logging.info(a)
out = '''Кто же будет первым курить *калик*?
Зарегистрируйся потом жми "Выдать калик".\n\nУчастники:'''
for indx, i in enumerate(a):
out += '\n' + str(indx + 1) + '. ' + str(i)
out += '\n\nПервым курит калик: ' + '@' + a[0]
a = []
bot.edit_message_text(out, call.message.chat.id, call.message.message_id, reply_markup=keyboard
, parse_mode='Markdown')
@bot.message_handler(commands=['hookah'])
def send_welcome(message):
global a
a = []
mes = bot.send_message(message.chat.id, '''Кто же будет первым курить *калик*?
Зарегистрируйся потом жми "Выдать калик".''', parse_mode='Markdown', reply_markup=keyboard)
# if mes.chat.type == 'supergroup':
# bot.pin_chat_message(mes.chat.id, mes.message_id)
bot.polling()