-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
204 lines (178 loc) · 6.73 KB
/
bot.py
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# -*- coding: utf-8 -*-
import telebot
import config
import botToken #contains token = '<token_here>'
import localization
import functions
import threading
import time
bot = telebot.TeleBot(botToken.token)
def getFurryArt(message):
try:
photo = open(str(functions.getRandomFurryArt()), 'rb')
bot.send_photo(message.chat.id, photo)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
return
class timerThread(threading.Thread):
cooldown = 0
def __init__(self):
threading.Thread.__init__(self)
def changeCooldown(self, newCooldown):
self.cooldown = newCooldown
def run(self):
time.sleep(self.cooldown)
#print('timer finished')
timer = timerThread()
timer.changeCooldown(config.cooldownForArts)
@bot.message_handler(commands=['furryart'])
def send_message(message):
global timer
if timer.is_alive():
try:
msg = bot.send_message(message.chat.id, 'Furryart command cooldown')
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
artThread = threading.Thread(target=getFurryArt, name='artThread', args=(message,))
#msg = bot.send_message(message.chat.id, 'Поток с артом запущен')
artThread.start()
while artThread.is_alive():
pass
#msg = bot.send_message(message.chat.id, 'Закончили поток с артом, запустили таймер')
timer = timerThread()
timer.changeCooldown(config.cooldownForArts)
timer.start()
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
return
@bot.message_handler(commands=['help', 'commands', 'start'])
def send_message(message):
if message.chat.id == config.furryGamersChatId: #Блок для чата Furry Gamers
try:
msg = bot.send_message(message.chat.id, localization.startMessageFull)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
msg = bot.send_message(message.chat.id, localization.startMessageShort)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['rules'])
def send_message(message):
if message.chat.id == config.furryGamersChatId: #Блок для чата Furry Gamers
try:
msg = bot.send_message(message.chat.id, localization.rulesForFG)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
msg = bot.send_message(message.chat.id, localization.rulesForOtherChats)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['voice', 'raidcall'])
def send_message(message):
if message.chat.id == config.furryGamersChatId: #Блок для чата Furry Gamers
try:
msg = bot.send_message(message.chat.id, localization.voiceForFG)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
msg = bot.send_message(message.chat.id, localization.voiceForOtherChats)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['contact'])
def send_message(message):
try:
msg = bot.send_message(message.chat.id, localization.masterContacts)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(content_types=['new_chat_participant'])
def send_message(message):
if message.chat.id == config.furryGamersChatId: #Блок для чата Furry Gamers
try:
msg = bot.send_message(message.chat.id, localization.newChatParticipantMessage)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
pass
@bot.message_handler(commands=['getcode'])
def send_message(message):
try:
msg = bot.send_message(message.chat.id, localization.getCodeBot)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['invitelink'])
def send_message(message):
if message.chat.id == config.furryGamersChatId: #Блок для чата Furry Gamers
try:
msg = bot.send_message(message.chat.id, config.inviteLink)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
msg = bot.send_message(message.chat.id, localization.inviteLinkForOtherChats)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['getchatid'])
def send_message(message):
if message.from_user.id == config.masterUserId:
try:
msg = bot.send_message(message.chat.id, str(message.chat.id))
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
msg = bot.send_message(message.chat.id, localization.unauthorizedAccessDeny)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['deal'])
def send_sticker(message):
try:
DealSticker = ''
DealSticker = open(functions.getCurrentDir() + '\Stickers\BillDeal.webp', 'rb')
bot.send_sticker(message.chat.id, DealSticker)
msg = bot.send_message(message.chat.id, localization.dealText)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['messageinfo'])
def send_message(message):
if message.from_user.id == config.masterUserId:
try:
msg = bot.send_message(message.chat.id, str(message))
msg = bot.send_message(message.chat.id, str(message.from_user.id))
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
msg = bot.send_message(message.chat.id, localization.unauthorizedAccessDeny)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['google'])
def send_message(message):
try:
if message.text == '/google' or message.text == '/google@WatchingEyeBot':
try:
msg = bot.send_message(message.chat.id, localization.searchEmpty)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
else:
try:
parsedString = functions.getParsed(message.text, '/google')
searchResults = functions.getGoogleResult(parsedString[2])
msg = bot.send_message(message.chat.id, searchResults)
except Exception:
msg = bot.send_message(message.chat.id, Exception)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
@bot.message_handler(commands=['moderators'])
def send_message(message):
try:
msg = bot.send_message(message.chat.id, localization.moderatorsList)
except Exception:
msg = bot.send_message(message.chat.id, localization.exceptionText)
bot.polling(none_stop=False)
while True:
pass