Advertisement
Iammrjude

Incrementing Balance with time in Telegram Bot.

Jun 10th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.56 KB | None | 0 0
  1. import telebot
  2. from telebot import types
  3. import re
  4. from dbHelp import DBHelper # Script that contains functions for my database
  5. import numpy
  6. import datetime
  7. import time
  8.  
  9. covidTOKEN="token"
  10.  
  11. bot=telebot.TeleBot(covidTOKEN)
  12.  
  13. @bot.message_handler(commands=['drop'])
  14. def drop_message(message):
  15.     db=DBHelper()
  16.     db.drop_table()
  17.  
  18. @bot.message_handler(commands=['start'])
  19. def start_message(message):
  20.     comnd=message.text
  21.     comndS=comnd.split(" ")
  22.     comSlast=comndS[-1]
  23.     if comSlast=='/start':
  24.         db=DBHelper()
  25.         db.setup()
  26.         markup = telebot.types.InlineKeyboardMarkup()
  27.         acct=telebot.types.InlineKeyboardButton(text='👤 Account', callback_data=1)
  28.         reg=telebot.types.InlineKeyboardButton(text='👥 Register', callback_data=2)
  29.         markup.row(acct,reg)
  30.         bot.send_message(message.chat.id, text="WELCOME\n\nCLICK ON 'REGISTER'.\n\n AFTER YOU REGISTER YOUR BALANCE WILL START TO INCREASE", reply_markup=markup,parse_mode='html')
  31.  
  32.  
  33. @bot.callback_query_handler(func=lambda call: True)
  34. def query_handler(call):
  35.     markup = telebot.types.InlineKeyboardMarkup()
  36.     acct=telebot.types.InlineKeyboardButton(text='👤 Account', callback_data=1)
  37.     reg=telebot.types.InlineKeyboardButton(text='👥 Referrals', callback_data=2)
  38.     bot.answer_callback_query(callback_query_id=call.id)
  39.    
  40.     if call.data == '1':
  41.         markup.row(acct,reg)
  42.         fname=call.message.chat.first_name
  43.         lname=call.message.chat.last_name
  44.         db=DBHelper()
  45.         bal1=db.get_amount()
  46.         if bal1==[]:
  47.             bal=0
  48.         else:
  49.             bal=bal1[0][0]
  50.         if lname==None:
  51.             user=fname
  52.         else:
  53.             user=fname+' '+lname
  54.         msg='👤 <b>GENERAL INFORMATION</b>\n\nâ—½ User: '+user+'\nâ—½ Balance: '+str(bal)+'\nâ—½ Account Type: Free\n\nâ—½ BTC wallet: '
  55.         bot.send_message(call.message.chat.id,msg,reply_markup=markup,parse_mode='html')
  56.    
  57.     elif call.data == '2':
  58.         db=DBHelper()
  59.         amtt1=db.get_amount()
  60.         if amtt1==[]:
  61.             t=time.time()
  62.             val=0
  63.             db.default_user(t,val)
  64.         p1=db.get_time()
  65.         p=p1[0][0]
  66.         time.sleep(4)
  67.         t=time.time()
  68.         while t-2>p:
  69.             if t-2>p:
  70.                 am=db.get_amount()
  71.                 val=am[0][0]
  72.                 value=val+10
  73.                 db.default_user(time.time(),value)
  74.                 p1=db.get_time()
  75.                 time.sleep(3)
  76.             p=p1[0][0]
  77.             t=time.time()
  78.         markup.row(acct,reg)
  79.         fname=call.message.chat.first_name
  80.         lname=call.message.chat.last_name
  81.         db=DBHelper()
  82.         if lname==None:
  83.             user=fname
  84.         else:
  85.             user=fname+' '+lname
  86.         msg="Well done "+user+" You have registered now your balance will start increasing. Click 'Account' to check your Balance"
  87.         bot.send_message(call.message.chat.id,msg,reply_markup=markup,parse_mode='html')
  88.        
  89. bot.polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement