Advertisement
Dimka_lang2

Untitled

Apr 6th, 2020
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.07 KB | None | 0 0
  1. import SimpleQIWI
  2. from SimpleQIWI import *
  3. import telebot
  4. import json
  5. import time
  6.  
  7. bot = telebot.TeleBot('*****************************************')
  8.  
  9. N53 = '7*********'
  10. api53 = '***********'
  11. N15 = '************'
  12. api15 = '***************'
  13. N00 = '**************'
  14. api00 = '*********************'
  15.  
  16. mainKeyboard = telebot.types.ReplyKeyboardMarkup(True, True)
  17. mainKeyboard.row('Балансы киви кошельков')
  18. mainKeyboard.row('Перевести все деньги на один кошелек')
  19.  
  20. qiwiBalances = telebot.types.ReplyKeyboardMarkup(True, True)
  21. qiwiBalances.row('узнать баланс киви ' + N15)
  22. qiwiBalances.row('узнать баланс киви ' + N53)
  23. qiwiBalances.row('узнать баланс киви ' + N00)
  24. qiwiBalances.row('Узнать общий баланс всех кошельков')
  25.  
  26. qiwisending = telebot.types.ReplyKeyboardMarkup(True, True)
  27. qiwisending.row('Отправить деньги на ' + N53)
  28. qiwisending.row('Отправить деньги на ' + N00)
  29. qiwisending.row('Отправить деньги на ' + N15)
  30.  
  31.  
  32. def QiwiBalance(number, apitoken):
  33.     api = QApi(token=apitoken, phone=number)
  34.     RuBalance = api.balance[0]
  35.     return RuBalance
  36.  
  37.  
  38. def All_balances(number, apitoken, number2, apitoken2, number3, apitoken3):
  39.     api = QApi(token=apitoken, phone=number)
  40.     RuBalance = api.balance[0]
  41.     api = QApi(token=apitoken2, phone=number2)
  42.     RuBalance2 = api.balance[0]
  43.     api = QApi(token=apitoken3, phone=number3)
  44.     RuBalance3 = api.balance[0]
  45.     AllEND_ball = RuBalance + RuBalance2 + RuBalance3
  46.     return AllEND_ball
  47.  
  48.  
  49. def sendingEnd(number, apitoken, mainQiwi):
  50.     fail = 'fail'
  51.     api = QApi(token=apitoken, phone=number)
  52.     BalanceQiwi = api.balance[0]
  53.     if BalanceQiwi > 1:
  54.         sendingAmout = int(api.balance[0]) * 0.98
  55.         print(sendingAmout)
  56.         api.pay(account=mainQiwi, amount=1, comment='Перевод всех бабок на 1 кивас')
  57.     else:
  58.         return fail
  59.  
  60.  
  61. def sendingEnd2(number2, apitoken2, mainQiwi):
  62.     fail2 = 'fail'
  63.     api = QApi(token=apitoken2, phone=number2)
  64.     BalanceQiwi = api.balance[0]
  65.     if BalanceQiwi > 1:
  66.         sendingAmout = int(api.balance[0]) * 0.98
  67.         print(sendingAmout)
  68.         api.pay(account=mainQiwi, amount=1, comment='Перевод всех бабок на 1 кивас')
  69.     else:
  70.         return fail2
  71.  
  72.  
  73. @bot.message_handler(commands=['start'])
  74. def start_message(message):
  75.     user_id_get = message.from_user.id
  76.     if user_id_get == 661081972:
  77.         bot.send_message(message.chat.id,
  78.                          'Приветствую, мой господин!',
  79.                          reply_markup=mainKeyboard)
  80.  
  81.  
  82. @bot.message_handler(content_types=['text'])
  83. def send_message(message):
  84.     user_id_get = message.from_user.id
  85.     if message.text == 'Балансы киви кошельков' and user_id_get == 661081972:
  86.         bot.send_message(message.chat.id, 'Выбирай то, что тебе нужно',
  87.                          reply_markup=qiwiBalances)
  88.  
  89.     if message.text == 'узнать баланс киви ' + N15 and user_id_get == 661081972:
  90.         End_balance = QiwiBalance(N15, api15)
  91.         bot.send_message(message.chat.id, 'Баланс киви кошелька : ' + str(End_balance) + 'Рублей',
  92.                          reply_markup=mainKeyboard)
  93.  
  94.     if message.text == 'узнать баланс киви ' + N53 and user_id_get == 661081972:
  95.         End_balance = QiwiBalance(N53, api53)
  96.         bot.send_message(message.chat.id, 'Баланс киви кошелька : ' + str(End_balance) + ' Рублей',
  97.                          reply_markup=mainKeyboard)
  98.  
  99.     if message.text == 'узнать баланс киви ' + N00 and user_id_get == 661081972:
  100.         End_balance = QiwiBalance(N00, api00)
  101.         bot.send_message(message.chat.id, 'Баланс киви кошелька : ' + str(End_balance) + 'Рублей',
  102.                          reply_markup=mainKeyboard)
  103.  
  104.     if message.text == 'Узнать общий баланс всех кошельков' and user_id_get == 661081972:
  105.         AlMyBalances = All_balances(N00, api00, N53, api53, N15, api15)
  106.         bot.send_message(message.chat.id, 'Общий баланс : ' + str(AlMyBalances) + ' Рублей ',
  107.                          reply_markup=mainKeyboard)
  108.  
  109.     if message.text == 'Перевести все деньги на один кошелек':
  110.         bot.send_message(message.chat.id, 'Выбирай нужный номер ',
  111.                          reply_markup=qiwisending)
  112.         bot.register_next_step_handler(message, userNumber)
  113.  
  114.  
  115. def userNumber(message):
  116.     userNum = message.text
  117.     user_id_get = message.from_user.id
  118.     if userNum == 'Отправить деньги на ' + N53 and user_id_get == 661081972:
  119.         print(userNum)
  120.         try:
  121.             first = sendingEnd(N00, api00, N53)
  122.             second = sendingEnd2(N15, api15, N53)
  123.             if first == 'fail':
  124.                 bot.send_message(message.chat.id, 'С киви  ' + N00 + ' не получилось перевести денег.Счет меньше 1 рубля ',
  125.                                  reply_markup=mainKeyboard)
  126.             else:
  127.                 bot.send_message(message.chat.id, 'С киви  ' + N00 + ' Деньги были переведены!',
  128.                                  reply_markup=mainKeyboard)
  129.             if second == 'fail':
  130.                 bot.send_message(message.chat.id,
  131.                                  'С киви ' + N15 + ' не получилось перевести денег.Счет меньше 1 рубля ',
  132.                                  reply_markup=mainKeyboard)
  133.             else:
  134.                 bot.send_message(message.chat.id, 'С киви  ' + N15 + ' деньги были переведены!',
  135.                                  reply_markup=mainKeyboard)
  136.  
  137.         except (SimpleQIWI.Errors.QIWIAPIError):
  138.             bot.send_message(message.chat.id, 'Баланс на одном из киви меньше минимального!',
  139.                              reply_markup=mainKeyboard)
  140.  
  141.     if userNum == 'Отправить деньги на ' + N00 and user_id_get == 661081972:
  142.         print(userNum)
  143.         try:
  144.             first = sendingEnd(N15, api15, N00)
  145.             second = sendingEnd2(N53, api53, N00)
  146.             if first == 'fail':
  147.                 bot.send_message(message.chat.id, 'С киви  ' + N15 + ' не получилось перевести денег.Счет меньше 1 рубля ',
  148.                                  reply_markup=mainKeyboard)
  149.             else:
  150.                 bot.send_message(message.chat.id, 'С киви  ' + N15 + ' Деньги были переведены!',
  151.                                  reply_markup=mainKeyboard)
  152.             if second == 'fail':
  153.                 bot.send_message(message.chat.id,
  154.                                  'С киви ' + N53 + ' не получилось перевести денег.Счет меньше 1 рубля ',
  155.                                  reply_markup=mainKeyboard)
  156.             else:
  157.                 bot.send_message(message.chat.id, 'С киви  ' + N53 + ' деньги были переведены!',
  158.                                  reply_markup=mainKeyboard)
  159.  
  160.         except (SimpleQIWI.Errors.QIWIAPIError):
  161.             bot.send_message(message.chat.id, 'Баланс на одном из киви меньше минимального!',
  162.                              reply_markup=mainKeyboard)
  163.  
  164.     if userNum == 'Отправить деньги на ' + N15 and user_id_get == 661081972:
  165.         print(userNum)
  166.         try:
  167.             first = sendingEnd(N00, api00, N15)
  168.             second = sendingEnd2(N53, api53, N15)
  169.             if first == 'fail':
  170.                 bot.send_message(message.chat.id,
  171.                                  'С киви  ' + N00 + ' не получилось перевести денег.Счет меньше 1 рубля ',
  172.                                  reply_markup=mainKeyboard)
  173.             else:
  174.                 bot.send_message(message.chat.id, 'С киви  ' + N00 + ' Деньги были переведены!',
  175.                                  reply_markup=mainKeyboard)
  176.             if second == 'fail':
  177.                 bot.send_message(message.chat.id,
  178.                                  'С киви ' + N53 + ' не получилось перевести денег.Счет меньше 1 рубля ',
  179.                                  reply_markup=mainKeyboard)
  180.             else:
  181.                 bot.send_message(message.chat.id, 'С киви  ' + N53 + ' деньги были переведены!',
  182.                                  reply_markup=mainKeyboard)
  183.  
  184.  
  185.         except (SimpleQIWI.Errors.QIWIAPIError):
  186.             bot.send_message(message.chat.id, 'Баланс на одном из киви меньше минимального!',
  187.                              reply_markup=mainKeyboard)
  188.  
  189.  
  190. bot.polling(none_stop=True, interval=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement