forked from Spolli/Darknet-Telegram-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (41 loc) · 1.78 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
#!/usr/bin/env python
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from urllib.request import urlopen
import logging
from view import *
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
bot_token = "630471052:AAFISIj7ZMAauSTPtzjEZEVBuyubOXCofb4"
def get_url(method):
return "https://api.telegram.org/file/bot{}/{}".format(bot_token, method)
def error(bot, update, error):
"""Log Errors caused by Updates."""
logger.warning('Update "%s" caused error "%s"', update, error)
def main():
"""Start the bot."""
updater = Updater(bot_token)
# Get the dispatcher to register handlers
dp = updater.dispatcher
# on different commands - answer in Telegram
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("help", help))
dp.add_handler(CommandHandler("vaffanculo", trigger))
# on noncommand i.e message - echo the message on Telegram
dp.add_handler(MessageHandler(Filters.photo, echoPhoto))
dp.add_handler(MessageHandler(Filters.video, echoVideo))
dp.add_handler(MessageHandler(Filters.audio, echoAudio))
dp.add_handler(MessageHandler(Filters.text, echoText))
# log all errors
dp.add_error_handler(error)
# Start the Bot
updater.start_polling()
# Run the bot until you press Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT. This should be used most of the time, since
# start_polling() is non-blocking and will stop the bot gracefully.
updater.start_webhook(listen='127.0.0.1', port=5002, url_path=bot_token)
#updater.bot.set_webhook(url='https://0.0.0.0/' + bot_token)
updater.idle()
if __name__ == '__main__':
main()