-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbridge.py
executable file
·54 lines (42 loc) · 1.65 KB
/
bridge.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
#!/usr/bin/python3
import telegram.ext as tbot
import configparser
import argparse
import os
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',level=logging.INFO)
def ExistingFile(path):
if os.path.isfile(path):
return path
raise argparse.ArgumentTypeError("'{}' is not a path to a file".format(path))
parser=argparse.ArgumentParser(description="Bridging with bots!")
parser.add_argument("config",nargs="?",help="Location of config file. Default: '%(default)s'",default='./config.ini',type=ExistingFile)
args=parser.parse_args()
config=configparser.ConfigParser()
config.read(args.config)
tConf=config['telegram']
TOKEN=tConf['token']
telegramOwner=tConf['owner'].lower() if 'owner' in tConf else None
updater=tbot.Updater(token=TOKEN)
dispatcher=updater.dispatcher
def ownerOnly(update,message):
if telegramOwner is None or update.message.from_user.username.lower()==telegramOwner:
update.message.reply_text(message)
else:
update.message.reply_text("i only take commands from master zangoose uwu")
def sayHi(bot,update):
#print(update)
#context.bot.send_message(chat_id=update.message.chat_id, text="I'm a bot, please talk to me!")
ownerOnly(update,"hewwo o3o")
#print("Starting in:",update,context)
#print("Chat id:",update.message.chat_id)
def getId(bots,update):
ownerOnly(update,"Chat Id: "+str(update.message.chat_id))
def echo(bot,update):
print(update)
hi_handler=tbot.CommandHandler('test', sayHi)
id_handler=tbot.CommandHandler('id', getId)
dispatcher.add_handler(hi_handler)
dispatcher.add_handler(id_handler)
#ispatcher.add_handler(tbot.MessageHandler(tbot.Filters.text, echo))
updater.start_polling()