Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telegram, json
- from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler, RegexHandler, ConversationHandler
- import os
- from os import system
- from time import strftime
- from telegram import Chat
- import bittrex
- def registerKS():
- bot.sendMessage(chat_id=update.message.chat_id, text="Please enter your API Key")
- AKey = update.message.text
- def choose():
- results = bot.sendMessage(chat_id=update.message.chat_id, text="Test", reply_markup={"keyboard":[["Account"], ["Balance"], ["VolT"], ["PercT"]]})
- return results
- def checkid():
- iduser = update.message.from_user.id
- iduser = str(iduser)
- path = os.path.dirname(os.path.abspath(__file__))+"/Datab/Users.json"
- fl = json.loads(open(path).read())
- for user in fl:
- if user==iduser:
- if fl[user]["activate"]==1:
- return True
- return False
- def menu(bot, update):
- unlocked = checkid()
- idu = update.message.from_user.id
- idu = str(idu)
- boolkey = checker("Key", idu)
- boolsec = checker("Secret", idu)
- if(not(boolkey) or not(boolsec)):
- bot.sendMessage("You still have to register your API Key and Secret.")
- registerKS()
- menu()
- if unlocked:
- choice = choose()
- if choice=="Account":
- Account()
- else if choice=="Balance":
- else if choice=="VolT":
- else if choice=="PercT":
- menu(bot, update)
- def activate(bot, update):
- idchat = update.message.chat_id
- if idchat==-183997848:
- path = os.path.dirname(os.path.abspath(__file__))+"/Datab/Users.json"
- fl = json.loads(open(path).read())
- stringa = update.message.text
- stringa = stringa.replace("/activate ", "")
- if fl[stringa]["activate"]==1:
- bot.sendMessage(chat_id=-183997848, text="Account already activated.")
- else:
- fl[stringa]["activate"] = 1
- bot.sendMessage(chat_id=-183997848, text="Account now activated.")
- with open(path, "w") as flw:
- flw.write(json.dumps(fl))
- return
- def add_user(idu):
- path = os.path.dirname(os.path.abspath(__file__))
- fl = json.loads(open(path+"/Datab/Users.json").read())
- fl[str(idu)] = {"activate":0}
- with open(path+"/Datab/Users.json", "w") as flw:
- flw.write(json.dumps(fl))
- def checker(tipo, data):
- path = os.path.dirname(os.path.abspath(__file__))+"/Datab/Users.json"
- fl = json.loads(open(path).read())
- if tipo=="ID":
- for user in fl:
- if user==data:
- return True
- return False
- elif tipo=="activate":
- for user in fl:
- if user==data:
- return fl[user]["activate"]
- elif tipo=="Key":
- for user in fl:
- if user==data:
- for entry in fl[user]:
- if entry=="Key":
- return True
- return False
- elif tipo=="Secret":
- for user in fl:
- if user==data:
- for entry in fl[user]:
- if entry=="Secret":
- return True
- return False
- def start(bot, update):
- unlocked = False
- user = update.message.from_user.username
- nick = update.message.from_user.first_name
- idu = update.message.from_user.id
- check_id = checker("ID", str(idu))
- if not(check_id):
- update.message.reply_text("Welcome to the Paprikat TradingBot!",parse_mode="markdown")
- bot.sendMessage(chat_id=update.message.chat_id, text="I see you're a new user! Contact @Knight_mare for the account activation.")
- add_user(idu)
- bot.sendMessage(chat_id=-183997848, text="Activation Request:\n\n@%s\n%s\nID = %s"%(user, nick, str(idu)))
- return
- check_status = checker("activate", str(idu))
- if check_id and check_status!=1:
- bot.sendMessage(chat_id=update.message.chat_id, text="Your account is not ready yet. Contact @Knight_mare for activation.")
- else:
- bot.sendMessage(chat_id=update.message.chat_id, text="Your account is activated and ready to use.")
- unlocked = True
- return
- def help(bot, update):
- bot.sendMessage(chat_id=update.message.chat_id,text="At the moment the command is under work.")
- return
- def status(bot, update):
- #idu = update.message.from_user.id
- # ##try:
- # nick = update.message.new_chat_member['first_name']
- # text = "Welcome KuriGoha-- Aehm, " + nick + "! uwu"
- # update.message.reply_text(text, quote=False)
- # print(strftime("%H:%M:%S -"), '%s joined a group! ID#(%s)' % (nick, idu))
- # return
- # except:
- # pass
- # try:
- # nick = update.message.left_chat_member['first_name']
- # text = "Sayonara " + nick + " o/"
- # update.message.reply_text(text, quote=False)
- # print(strftime("%H:%M:%S -"), '%s joined a group! ID#(%s)' % (nick, idu))
- # return
- # ##except:
- pass
- def register(bot, update):
- if update.message.chat.type== Chat.PRIVATE:
- idchat = update.message.chat_id
- add_user(idu)
- return
- def getid(bot, update):
- idchat = update.message.chat_id
- bot.sendMessage(chat_id=idchat,text=idchat)
- return
- def hint(bot, update):
- if update.message.chat.type == Chat.PRIVATE:
- while True:
- lmao = update.message.text
- if lmao.replace(" ","") == "/hint":
- lmao = update.message.text
- bot.sendMessage(chat_id=update.message.chat_id, text="Write now your suggestion.")
- while lmao.replace(" ","") == "/hint" and lmao!="Write now your suggestion.":
- lmao = update.message.text
- hint = update.message.text
- bot.sendMessage(chat_id=update.message.chat_id, text="Your suggestion is being sent.")
- break
- else:
- hint = lmao.replace("/hint ","")
- bot.sendMessage(chat_id=update.message.chat_id,text="Your suggestion is being sent.")
- break
- bot.sendMessage(chat_id= -183997848,text=("@"+update.message.from_user.username + " says: " + hint))
- return
- # def trying(bot, update):
- # results = bot.sendMessage(chat_id=update.message.chat_id, text="Test", reply_markup={"keyboard":[["Test1"], ["Test2"], ["Test3"], ["Test4"]]})
- # return results
- def reader(bot, update):
- user = update.message.from_user.username
- cont = update.message.text
- idg = update.message.chat.id
- idu = update.message.from_user.id
- return
- def main():
- updater = Updater("276224501:AAFuPg3olIKu1qrgZXe_g8qsCXiWAJhEnGg")
- dp = updater.dispatcher
- dp.add_handler(CommandHandler("start", start))
- dp.add_handler(CommandHandler("activate", activate))
- dp.add_handler(CommandHandler("menu", menu))
- # dp.add_handler(CommandHandler("trying", trying))
- dp.add_handler(CommandHandler("help", help))
- dp.add_handler(CommandHandler("hint", hint))
- dp.add_handler(CommandHandler("getid", getid))
- dp.add_handler(MessageHandler(Filters.text, reader))
- dp.add_handler(MessageHandler(Filters.status_update, status))
- updater.start_polling()
- updater.idle()
- if __name__ == '__main__':
- system("cls")
- print("Press CTRL+C to close the bot.")
- main()
- print(strftime("%H:%M:%S -"),"Bot has closed.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement