-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsp.py
More file actions
154 lines (135 loc) · 9.11 KB
/
Copy pathsp.py
File metadata and controls
154 lines (135 loc) · 9.11 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import telebot
import random
# import os
# from flask import Flask, request
from sksksks import *
TOKEN = '5880854228:AAFPO4PGV6gOtBot3f-2H_ytqm2qs5b57Y0'
bot = telebot.TeleBot(TOKEN)
# server = Flask(__name__)
sticker_id = ["CAACAgEAAxkBAAEJAg1kZHvQyvPQ5w-qHwTqNp7lDp4Y1AACCAADhy7gGgfIUDPuHksOLwQ", "CAACAgEAAxkBAAEJAg5kZHvQVC5WXM23rvGbxwhe_9BzrQACMgADhy7gGhl0yl2desA9LwQ", "CAACAgUAAxkBAAEJAg9kZHvQao4jgtVlo6kjRG0zPvibwQACfAkAAgQlwVfMh_gCAYukfC8E", "CAACAgUAAxkBAAEJAhBkZHvQrklA4XP03Hl2CJWQNJjmLQACSQADjzX8Djv2Sj3K4SEXLwQ", "CAACAgIAAxkBAAEJAhVkZHwm62BpUws8MjhhsRxvGc8S9gACVBMAAp5IyEsxwcY2Kt_j8S8E", "CAACAgUAAxkBAAEJAhdkZHxvIB3VkSGwmRtqM-9oh6H03wACPgQAAqWDpQj-Rthefz94oy8E"]
pooja_id = ["CAACAgUAAxkBAAEJAddkZHFQfrYEiAF_iQ0JtKnWIOVSWQACBgMAAqTLyVZ2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TlHDEMK0eejxJQAC7wIAAgpdyFaKU-H5Yfl8Ry8E", "CAACAgUAAxkBAAEJAgRkZHW91rCMyKxjEcu4xiJhhuWMUAAC8wEAAry9yFb6FA-xg-ozIy8E", "CAACAgUAAxkBAAEJAgVkZHW9R85h4mgTKHlgm17vBiaT-AACxwIAAp_S0VaoPZU4dIipGS8E", "CAACAgUAAxkBAAEJAgdkZHW-ThtMDS4P74K427HygYrYrgACOgIAAuAUyVZna2KkVUHQgy8E"]
inputs_m = {}
inputs_f = {}
outputs_m = {}
outputs_f = {}
count = {}
x
@bot.message_handler(commands=['start', 'restart'])
def start(message):
global inputs_m, inputs_f, count
user_id = message.chat.id
inputs_m[user_id] = {"M1":[],"M2":[],"M3":[],"M4":[],"M5":[],"M6":[]}
inputs_f[user_id] = {"F1":[],"F2":[],"F3":[],"F4":[],"F5":[],"F6":[]}
outputs_m[user_id] = {"M1":[],"M2":[],"M3":[],"M4":[],"M5":[],"M6":[]}
outputs_f[user_id] = {"F1":[],"F2":[],"F3":[],"F4":[],"F5":[],"F6":[]}
count[user_id] = 1
print(count)
instructions(message)
prompt(message)
@bot.message_handler(commands=['help'])
def help(message):
bot.send_message(message.chat.id, "Please do /instructions if you are unsure how to use the bot\n\nPlease do /result for the pairing results to be repeated\n\nIf you have any misinputs, please type /restart to start from the beginning")
@bot.message_handler(commands=['instructions'])
def instructions(message):
bot.send_message(message.chat.id, "Please input the rankings of M1 - M6 for F1 - F6 and vice versa\n\nFor each of the inputs, please input the rankings separated by a comma, 1 being most preferred and 6 being least. e.g. 5,6,3,2,1,4\n\nMake sure to check that the rankings given to you have one of each number from 1 - 6 (i.e. there should be NO duplicates)\n\nIf there are less than 12 people (e.g. missing M6 and F6), their entries should be 0,0,0,0,0,0 AND when people rank them in their ranking sheet, it should be 0 (e.g. there is no M6 and F6, so ranking slip could look like this: 2,3,4,5,6,0)\n\n Please do /help for other commands or contact @p0ngster or @meganyeo for assistance")
@bot.message_handler(commands=['result'])
def result(message):
global inputs_m, inputs_f, outputs_m, outputs_f
user_id = message.chat.id
if user_id not in inputs_m:
return start(message)
for key in inputs_m[user_id]:
if len(inputs_m[user_id][key]) == 0:
bot.send_message(message.chat.id, "bitch wtf there are no stored input values dumbfk")
return prompt(message)
outputs_m[user_id][key] = [int(i) for i in inputs_m[user_id][key]]
for key in inputs_f[user_id]:
if len(inputs_f[user_id][key]) == 0:
bot.send_message(message.chat.id, "bitch wtf there are no stored input values dumbfk")
return prompt(message)
outputs_f[user_id][key] = [int(i) for i in inputs_f[user_id][key]]
groups = split_into_groups(outputs_m[user_id], outputs_f[user_id])
bot.send_message(message.chat.id, f"The pairings are as follows:\n\n{groups[0][0]} {groups[0][1]}\n{groups[1][0]} {groups[1][1]}\n{groups[2][0]} {groups[2][1]}\n{groups[3][0]} {groups[3][1]}\n{groups[4][0]} {groups[4][1]}\n{groups[5][0]} {groups[5][1]}\n\nRefer to the above and pair up the freshies from the top to bottom pairings, ignore the respective pairings if freshie is not participating(e.g. Ignore M6 and F6 if they are not here).\n\nWhen splitting them into their respective rooms, try to make it as even as possible (e.g. if all 6 pairs are present, put first 3 pairs into one room, and the last 3 pairs into the other room.\n\nIf there are 5 pairs, put the first 3 pairs in one room, 4th and 5th pair in the other room) pairings are important as this will be the first pairing that will be used for the first game that is played together.")
def prompt(message):
global count
user_id = message.chat.id
if 1 <= count[user_id] <= 6:
bot.send_message(message.chat.id, f"Please enter M{count[user_id]}'s rankings of F1-F6")
elif 7 <= count[user_id] <= 12:
bot.send_message(message.chat.id, f"Please enter F{count[user_id] - 6}'s rankings of M1-M6")
else:
count[user_id] = 0
result(message)
def finished(message):
bot.send_message(message.chat.id, "All ranking strips have been submitted, if you would like a repeat of the result, please do /result.\n\nIf there was an error in the inputs, please do /restart and start from the beginning.")
@bot.message_handler(content_types=['photo', 'document'])
def handle_image(message):
photo_id = "AgACAgQAAxkBAAEhMeZkZOO24PdNdPmBAv-U5vIc9ycysQACSLAxG0exBFKe58XSrk7n6gEAAwIAA3gAAy8E"
return bot.send_photo(message.chat.id, photo_id)
@bot.message_handler(commands=['pooja'])
def pooja(message):
global pooja_id
bot.send_voice(message.chat.id, "AwACAgUAAxkBAAEhnhxkblGdQ142ovS1mmRBGsxSovYvaQACkQgAAq1cIFfYkK5O3RS6NS8E")
return bot.send_sticker(message.chat.id, random.choice(pooja_id))
@bot.message_handler(commands=['dontpressthis'])
def dontpressthis(message):
bot.send_sticker(message.chat.id, "CAACAgIAAxkBAAEJAiVkZH4bGC3m-bfQ2lVHqIwjh-odowACnREAAg3s0UtQX20y8kWzLi8E")
return bot.send_message(message.chat.id, "last warning i told you not to press this")
@bot.message_handler(content_types=['sticker'])
def handle_sticker(message):
global sticker_id
return bot.send_sticker(message.chat.id, random.choice(sticker_id))
@bot.message_handler(func=lambda message: True)
def handle_input(message):
global inputs_m, inputs_f, count
user_id = message.chat.id
try:
if user_id not in inputs_m:
return start(message)
input_list = message.text.split(',')
if len(input_list) != 6:
raise ValueError
if any(len(key) > 1 for key in input_list):
raise ValueError
input_set = set(input_list)
if len(input_set) != len(input_list) and '0' not in input_list:
print("error")
raise ValueError
for num in input_set:
if not num.isnumeric() or int(num) < 0 or int(num) > 6:
raise ValueError
if count[user_id] == 0:
print(count)
finished(message)
elif 0 < count[user_id] < 7:
name = "M" + str(count[user_id])
inputs_m[user_id][name] = (input_list)
count[user_id] += 1
# print(inputs_m)
print(count)
prompt(message)
else:
name = "F" + str(count[user_id] - 6)
inputs_f[user_id][name] = (input_list)
count[user_id] += 1
# print(inputs_f)
print(count)
prompt(message)
except ValueError:
if count[user_id] == 0:
return finished(message)
else:
bot.send_message(message.chat.id, "Invalid input. Please enter 6 unique digits separated by commas e.g. 5,6,3,2,1,4. Ranking score should not exceed 6.\n\nPlease do /restart if you made a mistake with the inputs or are unsure of how to input the rankings.")
prompt(message)
bot.polling()
# @server.route('/' + TOKEN, methods=['POST'])
# def getMessage():
# bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
# return "!", 200
# @server.route("/")
# def webhook():
# bot.remove_webhook()
# bot.set_webhook(url='https://secretpartnerbotbot.herokuapp.com/' + TOKEN)
# return "!", 200
# if __name__ == "__main__":
# server.run(host="0.0.0.0", port=int(os.environ.get('PORT', 5000)))