· 5 years ago · Jun 25, 2020, 01:52 AM
1import os
2import json
3import requests
4import random
5import sys
6import telebot
7import mysql.connector
8import logging
9import xlrd, xlwt
10import re
11import supp as sp
12import checker as checker
13
14# Enable logging
15logging.basicConfig(filename='ccbot_log.txt', filemode='w',
16 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
17 level=logging.DEBUG)
18logger = logging.getLogger(__name__)
19
20bot = telebot.TeleBot('1274486011:AAEluJgNbV7apT2VXLP4WZIC_iLBXgcjbUM')
21
22db = mysql.connector.connect(
23 host="localhost",
24 user="ccbotbase",
25 passwd="r@@t00",
26 port="3306",
27 database="user_cc"
28)
29cursor = db.cursor()
30cursor.execute("CREATE DATABASE IF NOT EXISTS user_cc")
31cursor.execute("CREATE TABLE IF NOT EXISTS customers (id VARCHAR(255) UNIQUE, username VARCHAR(255), cr INT)")
32cursor.execute(
33 "CREATE TABLE IF NOT EXISTS cclist (id VARCHAR(255), username VARCHAR(255), cc VARCHAR(255), reply VARCHAR(255))")
34
35boss = 768558451
36
37
38@bot.message_handler(commands=['help'])
39def help11(message):
40 bot.send_photo(message.chat.id, photo=open('help.jpg', 'rb'),
41 caption='По всем вопросам обращайтесь в поддержку\n @xg3er')
42
43@bot.message_handler(commands=['balance'])
44def topup(message):
45 user_id = message.from_user.id
46 sql0 = "SELECT cr FROM customers WHERE id = %s"
47 id = (user_id,)
48 cursor.execute(sql0, id)
49 cr = cursor.fetchone()
50 for x in cr:
51 rob = x
52 bot.send_photo(message.chat.id, photo=open('bal.jpg', 'rb'),
53 caption='Remain credits: *%s*\n\n1 credit = ###\n\nIn order to TOPUP your balance, please PM\n @xg3er' % rob, parse_mode="markdown")
54
55
56@bot.message_handler(commands=['check'])
57def check1(message):
58 markup = telebot.types.InlineKeyboardMarkup()
59 markup.add(telebot.types.InlineKeyboardButton(text='\U0001F4B3 CHECK SINGLE CC', callback_data=3))
60 markup.add(telebot.types.InlineKeyboardButton(text='\U0001F4B3 CHECK BULK CC', callback_data=4))
61 user_id = message.from_user.id
62 sql0 = "SELECT cr FROM customers WHERE id = %s"
63 id = (user_id,)
64 cursor.execute(sql0, id)
65 cr = cursor.fetchone()
66 db.commit()
67 for x in cr:
68 rob = x
69 bot.send_photo(message.chat.id, photo=open('bph4.jpg', 'rb'),
70 caption=(
71 "Your ID: `%s` (tap to copy)\nYour credits: *%s*\n\n\n*CC* input format:"
72 "\nnnnnnnnnnnnnnnnn mmyy cvv\n\n *BULK CC* input format:"
73 "\nnnnnnnnnnnnnnnnn mmyy cvv\nnnnnnnnnnnnnnnnn mmyy cvv\nnnnnnnnnnnnnnnnn mmyy cvv /help" %
74 (user_id, rob)), reply_markup=markup, parse_mode="markdown")
75
76
77@bot.message_handler(commands=['start'])
78def mainmenu(message):
79 markup = telebot.types.InlineKeyboardMarkup()
80 markup.add(
81 telebot.types.InlineKeyboardButton(text='BARBIE CHAT', url="https://t.me/joinchat/LH6hJRT4-9xmBbH6YjImcA"))
82 markup.add(telebot.types.InlineKeyboardButton(text='\U0001F4B3 CHECK CC', callback_data=3))
83 markup.add(telebot.types.InlineKeyboardButton(text='reserved', callback_data=5))
84 user_id = message.from_user.id
85 username = message.from_user.username
86 if user_id == boss:
87 try: # без этого если таблицы не было, бот вылеоает с ошибкой
88 cr = 100
89 sql = "INSERT INTO customers (id, cr) VALUES (%s, %s)"
90 val = (user_id, cr)
91 cursor.execute(sql, val)
92 db.commit()
93 except:
94 pass
95 keyboard = telebot.types.ReplyKeyboardMarkup(True)
96 keyboard.row('/start', '/check')
97 keyboard.row('/addcr', '/dldcc', '/dldusr')
98
99 sql0 = "SELECT cr FROM customers WHERE id = %s"
100 id = (user_id,)
101 cursor.execute(sql0, id)
102 cr = cursor.fetchone()
103 for x in cr:
104 rob = x
105 bot.send_photo(message.chat.id, photo=open('bph2.png', 'rb'),
106 caption=(
107 "_Hi, BOSS! BARBIE is here!_\n\nYour ID: `%s` (tap to copy)\n"
108 "Your credits: *%s*\n\n\nCC input format:\nnnnnnnnnnnnnnnnn mmyy cvv\n\n\n"
109 %
110 (user_id, rob)), reply_markup=markup, parse_mode="markdown")
111 bot.send_audio(message.chat.id, audio=open('mom.ogg', 'rb'), reply_markup=keyboard)
112
113 else:
114 keyboard = telebot.types.ReplyKeyboardMarkup(True)
115 keyboard.row('\U0001F4B3 CHECK CC')
116 keyboard.row('\U0001F646 Home', '\U0001F4B0 Balance', '\U0001F481 Help')
117
118 try:
119 cr = 5
120 sql = "INSERT INTO customers (id, username, cr) VALUES (%s, %s, %s)"
121 val = (user_id, username, cr)
122 cursor.execute(sql, val)
123 db.commit()
124
125 bot.send_photo(message.chat.id, photo=open('bph2.png', 'rb'),
126 caption=(
127 "Welcome! *BARBIE* is here to check your CC!\nYour ID: `%s` (tap to copy)\n\n*WOW! You have 5 free credits!*\nYour credits: *%s*\n\n\nCC input format:\nnnnnnnnnnnnnnnnn mmyy cvv" %
128 (user_id, cr)), reply_markup=markup, parse_mode="markdown")
129 bot.send_audio(message.chat.id, audio=open('mom.ogg', 'rb'), reply_markup=keyboard)
130 except:
131 sql0 = "SELECT cr FROM customers WHERE id = %s"
132 id = (user_id,)
133 cursor.execute(sql0, id)
134 cr = cursor.fetchone()
135 db.commit()
136
137 for x in cr:
138 rob1 = x
139 bot.send_photo(message.chat.id, photo=open('bph2.png', 'rb'),
140 caption=(
141 "Hi, handsome! *BARBIE* is here to check your CC!\n\nYour ID: `%s` (tap to copy)\n"
142 "Your credits: *%s*\n\n\nCC input format:\nnnnnnnnnnnnnnnnn mmyy cvv\n\n\n"
143 %
144 (user_id, rob1)), reply_markup=markup, parse_mode="markdown")
145 bot.send_audio(message.chat.id, audio=open('mom.ogg', 'rb'), reply_markup=keyboard)
146
147
148@bot.callback_query_handler(func=lambda call: True)
149def query_handler(call):
150 # answer = ''
151 if call.data == '3':
152 user_id = call.message.chat.id
153 sql0 = "SELECT cr FROM customers WHERE id = %s"
154 id = (user_id,)
155 cursor.execute(sql0, id)
156 cr = cursor.fetchone()
157 for x in cr:
158 if int(x <= 0):
159 bot.send_message(call.message.chat.id, "извините мало кредитов")
160 else:
161 msg = bot.send_message(call.message.chat.id, 'Enter CC number')
162 bot.register_next_step_handler(msg, checker.ccheck)
163
164 elif call.data == '4':
165 user_id = call.message.chat.id
166 sql0 = "SELECT cr FROM customers WHERE id = %s"
167 id = (user_id,)
168 cursor.execute(sql0, id)
169 cr = cursor.fetchone()
170 for x in cr:
171 if int(x <= 0):
172 bot.send_message(call.message.chat.id, "извините мало кредитов")
173 else:
174 msg = bot.send_message(call.message.chat.id, 'Enter BULK number')
175 bot.register_next_step_handler(msg, checker.bulkcc)
176
177
178# ================================== служебные команды ============================================
179
180@bot.message_handler(commands=['addcr'])
181def start_message2(message):
182 uid = message.from_user.id
183 if uid == boss:
184 msg = bot.send_message(message.chat.id, "Please enter UID")
185 bot.register_next_step_handler(msg, check_credit)
186 else:
187 bot.send_message(message.chat.id, "ACCESS DENIED. Иди на хуй, Николя")
188
189
190def check_credit(message): # проверка количества кредитов
191 uid3 = message.text
192 global idc # вот эти две ебучие строчки которые я искал
193 idc = uid3 # переменная назначается в функции, а сама выносится за пределы функции
194 try:
195 ssql = "SELECT cr FROM customers WHERE id = %s"
196 id = (uid3,)
197 cursor.execute(ssql, id)
198 cr = cursor.fetchone()
199 for x in cr:
200 ucr = x
201 bot.send_message(message.chat.id, "Кредитов есть:")
202 bot.send_message(message.chat.id, ucr)
203 msg = bot.send_message(message.chat.id, "сколько добавить кредитов?")
204 bot.register_next_step_handler(msg, add_credit)
205 except:
206 msg = bot.send_message(message.chat.id, "Invalid UID. Please enter UID")
207 bot.register_next_step_handler(msg, check_credit)
208
209
210def add_credit(message): # добавление кредитов
211 try:
212 addcr = int(message.text)
213 ssql1 = "SELECT cr FROM customers WHERE id = %s"
214 id = (idc,)
215 cursor.execute(ssql1, id)
216 cr = cursor.fetchone()
217 for x in cr:
218 updcr1 = int(x + addcr)
219
220 ssql2 = "UPDATE customers SET cr = %s WHERE id = %s"
221 val2 = (updcr1, idc,)
222 cursor.execute(ssql2, val2)
223
224 db.commit()
225 bot.send_message(message.chat.id, "Кредиты успешно добавлены! Теперь:")
226 bot.send_message(message.chat.id, updcr1)
227 except:
228 msg = bot.send_message(message.chat.id, "Invalid entry. ")
229 bot.send_message(message.chat.id, "сколько добавить кредитов?")
230 bot.register_next_step_handler(msg, add_credit)
231
232
233@bot.message_handler(commands=['dldusr'])
234def user_list(message):
235 uid = message.from_user.id
236 if uid == boss:
237 bot.send_message(message.chat.id, "Список юзеров:")
238 sp.usrlist(message)
239 else:
240 bot.send_message(message.chat.id, "Иди на хуй, Николя")
241
242
243@bot.message_handler(commands=['dldcc'])
244def cc_list(message):
245 uid = message.from_user.id
246 if uid == boss:
247 bot.send_message(message.chat.id, "Список:")
248 sp.cclist(message)
249 else:
250 bot.send_message(message.chat.id, "Иди на хуй, Николя")
251
252#========================================================================
253
254@bot.message_handler(content_types=['text'])
255def message_handler(message):
256 if message.text == '\U0001F481 Help':
257 help11(message)
258 elif message.text == '\U0001F4B3 CHECK CC':
259 check1(message)
260 elif message.text == '\U0001F646 Home':
261 mainmenu(message)
262 elif message.text == '\U0001F4B0 Balance':
263 topup(message)
264 else:
265 pass
266
267#
268#
269# @bot.message_handler(commands=['vld'])
270# def start_message4(message):
271# bot.send_message(message.chat.id, "введи ссщку")
272# @bot.message_handler(content_types=['text'])
273# def validate(message):
274# cc = str(message.text)
275# pattern = '^[973][0-9]{15}|[973][0-9]{3}-[0-9]{4}-[0-9]{4}-[0-9]{4}$'
276# result = re.match(pattern, cc)
277# print(result)
278# # for x in cc:
279# # result = re.match(pattern, x)
280# # print(result)
281# # if result:
282# # bot.send_message(message.chat.id, "отличная ссшка")
283# # else:
284# # bot.send_message(message.chat.id, "плохая ссшка")
285#
286#
287
288
289bot.polling(none_stop=True, interval=0)
290if __name__ == '__main__':
291 main()