-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
133 lines (106 loc) · 4.1 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
import telebot
import config # BOT_TOKEN token got from FatherBot
import content_messages
import checks
import re
from threading import Thread
bot = telebot.TeleBot(config.BOT_TOKEN)
chat_id = 0
count = 0
links = ""
chats_id = []
# fSticker = open("sources/F.webp", 'rb')
def counter():
global count
count += 1
return count
def threadingTester():
while():
text = str(input())
if(text != "!quit"):
for id in chats_id:
bot.send_message(
id, text
)
else:
break
def switchText(text):
layout_to_rus = dict(zip(map(ord, "qwertyuiop[]asdfghjkl;'zxcvbnm,./`"
'QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?~'),
"йцукенгшщзхъфывапролджэячсмитьбю.ё"
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,Ё'))
text = str(text)
if (re.search(r'[а-яА-ЯёЁ]', text)):
layout_to_eng = dict(zip(map(ord, "йцукенгшщзхъфывапролджэячсмитьбю.ё"
'ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,Ё'),
"qwertyuiop[]asdfghjkl;'zxcvbnm,./`"
'QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?~'))
return (text.translate(layout_to_eng))
return (text.translate(layout_to_rus))
@bot.message_handler(commands=['start'])
def welcome(message):
bot.send_message(message.chat.id,
content_messages.START_TEXT,
parse_mode='markdown')
if message.chat.id not in chats_id:
chats_id.append(message.chat.id)
# chat_id = message.chat.id
@bot.message_handler(commands=['help'])
def help(message):
bot.send_message(message.chat.id,
content_messages.HELP_TEXT)
@bot.message_handler(commands=['pleh'])
def pleh(message):
bot.send_message(message.chat.id,
"PLEH COMING SOON...")
@bot.message_handler(commands=['switch'])
def switch(message):
if message.reply_to_message is not None:
print (message.reply_to_message)
if message.reply_to_message.content_type == 'text':
if message.reply_to_message:
bot.send_message(
message.chat.id,
switchText(message.reply_to_message.text),
reply_to_message_id=message.reply_to_message.id
)
else:
bot.send_message(
message.chat.id, "Please reply on the TEXT message.", reply_to_message_id=message.id
)
if message.reply_to_message is not None:
if message.reply_to_message.content_type != 'text':
if message.reply_to_message:
bot.send_message(
message.chat.id,
switchText(message.reply_to_message.caption),
reply_to_message_id=message.reply_to_message.id
)
else:
bot.send_message(
message.chat.id, "Please reply on the TEXT message.", reply_to_message_id=message.id
)
print(message.reply_to_message.caption)
if message.reply_to_message is None:
bot.send_message(
message.chat.id, "Please REPLY on the TEXT message.", reply_to_message_id=message.id
)
@bot.message_handler(commands=['howmuchmessages'])
def countmsgs(message):
counts = counter()
bot.send_message(message.chat.id, str(counts))
print(counts)
@bot.message_handler(content_types=['text'])
def forwarding(message):
print(message)
checks.triggerCheck(message, bot)
print(message.chat.id)
@bot.message_handler(content_types=['photo'])
def forwall(message):
print(str(message) + '\n' + 'ATTENTION!!! IMAGE ')
print("Bot was started, waiting for a dialog")
botThread = Thread(target=bot.polling, args=({"none_stop": True},))
botThread.start()
adminBackThread = Thread(target=threadingTester, args=())
adminBackThread.start()
# bot.polling(none_stop=True)