-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
62 lines (32 loc) · 1.39 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
import os
import random
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from telegram import ReplyKeyboardMarkup, Contact
import logging
#relacionado a erros e excessões -
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
def cheat_response(update,context):
if context.args:
letter = str(context.args[0])
#create a .txt list
txt_list = os.listdir('letters/'+letter.lower())
#passes through the list showing random words
for i in txt_list:
word = open('letters/'+letter+'/'+i,'r').read().splitlines()
num = random.randint(0, len(word))
context.bot.send_message(chat_id=update.effective_chat.id, text= '%s: %s' % (i.replace('.txt', '').capitalize(),word[num].capitalize()))
else:
context.bot.send_message(chat_id=update.effective_chat.id, text='Você não passou nenhuma letra!')
def main():
file_token = open("token.txt", "r")
token = file_token.read().splitlines()
file_token.close()
updater = Updater(token=token[0] , use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("cheat", cheat_response))
updater.start_polling()
logging.info("=== Engines On! ===")
updater.idle()
logging.info("=== Turn off! === ")
if __name__ == '__main__':
main()