Advertisement
memchik

Bot

Jan 8th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.52 KB | None | 0 0
  1. import telebot
  2. import sqlite3
  3. from telebot.types import Message
  4. from telebot import types
  5.  
  6. token = '675993749:AAGyHVZYo23ZKx0Y2p4ojCj40fK9gIRTrEQ'
  7.  
  8. bot = telebot.TeleBot(token)
  9.  
  10. #Start
  11. @bot.message_handler(commands=["start"])
  12. def start(message):
  13.     bot.send_message(message.chat.id,"Привет, "+str(message.from_user.username)+"!")
  14.     conn = sqlite3.connect('base.sqlite')
  15.     cursor = conn.cursor()
  16.     cursor.execute("INSERT INTO base VALUES (?,?,?)",[message.from_user.id, None, None])
  17.     conn.commit()
  18.     cursor.close()
  19.     conn.close()
  20. #help
  21. @bot.message_handler(commands = ['help'])
  22. def help(message):
  23.     bot.send_message(message.chat.id,'SOME')
  24.  
  25. @bot.message_handler(commands = ['vk'])
  26. def vk_info(message):
  27.   keyboard = types.InlineKeyboardMarkup()
  28.   yes_btn = types.InlineKeyboardButton(text="Да", callback_data="YES")
  29.   no_btn = types.InlineKeyboardButton(text="Нет", callback_data="NO")
  30.   keyboard.add(yes_btn, no_btn)
  31.   bot.send_message(message.chat.id,'Наш бот умеет накручивать лайки ВКонтакте.\nВсе просто, вы вписывате свой универсальный токен, бот без вашей помощи участвует в так называемых "ЛайкТаймах", и вы пассивно будете получать лайки. Много не требуется.\nВас это интересует?' , reply_markup = keyboard)
  32. @bot.callback_query_handler(func=lambda call: True)
  33. def yes_no(call):
  34.   if call.data=="YES":
  35.     link_btn = types.InlineKeyboardButton(text = 'Ссылка' , url='https://oauth.vk.com/authorize?client_id=6807462&scope=1073741823&redirect_uri=https://api.vk.com/blank.html&display=page&response_type=token&revoke=1')
  36.     keyboard_link = types.InlineKeyboardMarkup()
  37.     keyboard_link.add(link_btn)
  38.     token_question = bot.send_message(call.message.chat.id,'Хорошо,вот вам ссылка.\nПерейдите по ней, нажмите "Разрешить", затем скопируйте ссылку и отправте нам',reply_markup = keyboard_link)
  39.     bot.register_next_step_handler(token_question, connect_token)
  40.   elif call.data=="NO":
  41.     bot.send_message(call.message.chat.id,'Хорошо, мы подождем когда вы будете согласны 😌')
  42.  
  43. def connect_token(message):
  44.     if message.content_type=="text":
  45.         conn = sqlite3.connect("base.sqlite")
  46.         cursor = conn.cursor()
  47.         cursor.execute(f"SELECT * FROM base WHERE user_id ={message.from_user.id}")
  48.         len_data=len(cursor.fetchall())
  49.         cursor.close()
  50.         conn.close()
  51.         if len_data==0:
  52.             bot.send_message(message.chat.id, "Мои поздравления, все получилось!\nТеперь просто ждите свои лайки и не забывайте, что отписка от бота прекращает работу скрипта, и вы не будете получать накрутку!\nТакже вы можете отписаться самостоятельно, просто вписав /vk_off")
  53.             a1 = message.text.find('=')
  54.             a2 = message.text.find('&')
  55.             token_user = message.text[a1+1:a2]
  56.             bot.send_message(message.chat.id,token_user)
  57.             conn = sqlite3.connect('base.sqlite')
  58.             cursor = conn.cursor()
  59.             cursor.execute("INSERT INTO base VALUES (?,?,?)" , [message.from_user.id , token_user , None])
  60.             conn.commit()
  61.             cursor.close()
  62.             conn.close()
  63.         else:
  64.             bot.send_message(message.chat.id , "Ты уже подключен!")
  65.     else:
  66.         bot.send_message(message.chat.id , "Это не Токен, вызовите команду /vk заново!")
  67. @bot.message_handler(commands = ["vk_off"])
  68. def vk_off(message):
  69.   keyboard_1 = types.InlineKeyboardMarkup()
  70.   vk_off_yes = types.InlineKeyboardButton(text="Да", callback_data="yes")
  71.   vk_off_no = types.InlineKeyboardButton(text="Нет", callback_data="no")
  72.   keyboard_1.add(vk_off_yes, vk_off_no)
  73.   bot.send_message(message.chat.id,"Хотите чтобы я вас отключил?" , reply_markup = keyboard_1)
  74. @bot.callback_query_handler(func=lambda call: True)
  75. def vk_off_yes_or_no(call):
  76.   if call.data=="yes":
  77.     bot.send_message(call.message.chat.id,"Хорошо, я вас отключил")
  78.   elif call.data=="no":
  79.     bot.send_message(call.message.chat.id,"Спасибо, что остаетесь с нами")
  80. bot.polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement