-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
43 lines (26 loc) · 1.09 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
from loguru import logger
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import config
def start(bot, update):
bot.send_message(chat_id=update.message.chat_id, text='Hi!')
def help(bot, update):
bot.send_message(chat_id=update.message.chat_id, text='Help!')
def echo(bot, update):
update.message.reply_text(update.message.text, reply_to_message_id=update.message.message_id)
def welcome(bot, update):
welcome_msg = "Seja bem vindo ao Grupy-RN!"
update.message.reply_text(welcome_msg, reply_to_message_id=update.message.message_id)
def error(bot, update):
logger.warning(f'Update {bot} caused error {update.error}')
def main():
updater = Updater(config.BOT_TOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("help", help))
dp.add_handler(MessageHandler(Filters.text, echo))
dp.add_handler(MessageHandler(Filters.status_update.new_chat_members, welcome))
dp.add_error_handler(error)
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()