-
Notifications
You must be signed in to change notification settings - Fork 15
/
mayo.py
45 lines (37 loc) · 1.22 KB
/
mayo.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
'''gives the previous command m a y o n n a i s e'''
import random
import re
import string
__author__ = ('iandioch')
COMMAND = 'mayo'
FORMATS = [
'Ara, {}!',
'{} ara.',
'ara {}.',
'{} #mayo4sam',
'{} #mayoforsam',
]
def mayo(message):
message += ' '
message = message.lower()
message = message.replace('the', 'de') # !important
message = message.replace('s', 'sh')
message = message.replace('sh ', 's ')
message = message.replace('shh', 'sh')
sentences = re.split('[.,!?]', message)
out = ''
for s in sentences:
if random.random() < 0.4:
out += random.choice(FORMATS).format(s) + ' '
else:
out += s + ' '
return out
def main(bot, author_id, message, thread_id, thread_type, **kwargs):
message = bot.fetchThreadMessages(thread_id=thread_id, limit=2)[1]
mayonnaise = mayo(message.text)
bot.sendMessage(mayonnaise, thread_id=thread_id, thread_type=thread_type)
if __name__ == '__main__':
print(mayo('lorem ipsum dolor sit amet'))
print(mayo('Brexit: Barnier warns UK there is ‘no going back’ on deal'))
print(mayo('Abortion committee set to recommend allowing terminations up to 12 weeks'))
print(mayo('cash'))