-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
99 lines (81 loc) · 3.53 KB
/
main.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
from tornado import gen, ioloop
from telezombie import api
import re
from random import choice
from api_token import API_TOKEN
def make_x(s):
vocals = 'аеёиоуыэюя'
for i, l in enumerate(s):
if l in vocals and i != len(s) - 1:
if l == 'о':
l1 = 'е'
elif l == 'а':
l1 = 'я'
elif l == 'у':
l1 = 'ю'
elif l == 'ы':
l1 = 'и'
elif l == 'э':
l1 = 'е'
else:
l1 = l
return 'ху' + l1 + s[i + 1:]
return s
class Xuificator(api.TeleLich):
XUI_PHRASES = ['Ну же, пиши хуй, не стесняйся!',
'Че цензуришь? Не четкий чель?',
'В жопу себе звездочки поставь',
'Орел комнатный? Без цензуры не можешь?',
'Раз, два, три... Звездочки нахуй убери!']
RUDE_PHRASES = ['ПВП или зассал?',
'Тебя мама по губам отшлепает',
'Я не буду больше с тобой разговаривать',
'Тебе не надоело?',
'Не приставай ко мне',
'Заебываешь, блять!',
'Я тебя по IP вычислю!',
'Я если я тебя в реале найду?',
'Нахуй иди',
'Иди нахуй',
'Поешь говна, грубиян-хуиян']
def __init__(self, api_token):
super(Xuificator, self).__init__(api_token)
@gen.coroutine
def on_text(self, message):
chat = message.chat
lt = message.text.lower()
additions = ''
# Не надо цензуры!
p = re.compile(r'х[!@#$%^&*()]+[йяюи]')
if p.search(lt):
yield self.send_message(chat.id_, choice(self.XUI_PHRASES))
return
if lt.find('это ') == 0:
lt = lt[4:]
additions = 'это '
# Не надо обижать бота!
# p = re.compile(
# r'(х(у+)(й|и|ю|я|е))|(дурак)|(идиот)|(лох)|(лош(о|а))|(пид(о|р))|(педик)|(г(о|а)ндон)|с(у+)(к|ч|(чк))(а+)|(муд(о|а))')
p = re.compile(
r'((сам)? ?(ты)? ?(сам)?|((по)?сл(у|ы)ш(ай)?)) ?,? (х(у+)(й|и|ю|я|е))|(дурак)|(идиот)|(лох)|(лош(о|а))|(пид(о|р))|(педик)|(г(о|а)ндон)|с(у+)(к|ч|(чк))(а+)|(муд(о|а))')
if p.search(lt):
yield self.send_message(chat.id_, choice(self.RUDE_PHRASES))
return
text = lt.split(' ')
if text[0][0] == '/':
# Не обрабатываем команды. Особенно от сторонних ботов.
return
text = [make_x(x) for x in text if x != '@xuifikatorbot' and x[0] != '/']
res = ' '.join(text)
if res[-1:] == '?':
res = res[:-1] + ', блять!'
if additions:
res = "%s %s" % (additions, res)
yield self.send_message(chat.id_, res)
@gen.coroutine
def forever():
proc = Xuificator(API_TOKEN)
yield proc.poll()
if __name__ == "__main__":
main_loop = ioloop.IOLoop.instance()
main_loop.run_sync(forever)