-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
1228 lines (906 loc) · 38.1 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf8 -*-
import random
from random import randint
import string
import telebot
from telebot import types
import requests
import sqlite3
import json
import os
from config import token,admin,vxodadmin,vxodworker,maxpromo,minimalka,maximalka,zalety,bot_username
from buttons import b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b22
from buttons import userpanel,menu,empty,cancel,bal
from answers import a0,a1,a11,a19,skolkochasov
bot=telebot.TeleBot(token)
@bot.message_handler(commands=['start'])
def send_welcome(message):
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from users where id = {message.chat.id}")
if cur.fetchone()[0] == 0:
con.commit()
ref = message.text
if len(ref) != 6:
try:
ref = int(ref[7:])
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from users where id = {ref}")
if cur.fetchone()[0] != 0:
con.commit()
boss = ref
else:
con.commit()
boss = admin
except:
boss = admin
else:
boss = admin
id = message.chat.id
name = (f"{message.chat.first_name} {'|'} {message.chat.last_name}")
referals = 0
user_name = message.chat.username
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"INSERT INTO users (id,name,referals,boss, username,photoid,balance) "
f"VALUES ({id},\"{name}\",{referals},{boss}, \"{user_name}\",{1},{0})")
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"SELECT referals FROM users WHERE id = {boss}")
referal = cur.fetchone()[0]
referals = referal + 1
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE users SET referals = {referals} WHERE id = {boss}")
con.commit()
bot.send_message(message.chat.id, f"🤗 Привет {message.chat.first_name}", reply_markup=userpanel())
bot.send_message(boss, f"У вас новый мамонт {message.chat.first_name}")
else:
con.commit()
bot.send_message(message.chat.id, f"🤗 Привет {message.chat.first_name}", reply_markup=userpanel())
@bot.message_handler(content_types="text")
def main_message(message):
if message.text == b0:
bot.send_message(message.chat.id,a0)
elif message.text==b1:
try:
keyboard = types.InlineKeyboardMarkup()
q1 = types.InlineKeyboardButton(text=b14, callback_data="vybor")
q2 = types.InlineKeyboardButton(text=b15, callback_data="photos")
q3 = types.InlineKeyboardButton(text=b16, callback_data="prew")
q4 = types.InlineKeyboardButton(text=b17, callback_data="next")
keyboard.add(q1,q2)
keyboard.add(q3,q4)
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
dostup=cur.fetchone()[0]
con.commit()
if dostup == 0:
bot.send_message(message.chat.id, "Анкеты пока не доступны")
else:
bot.send_message(message.chat.id,a1,reply_markup=menu())
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select photoid from users where id = {message.chat.id}")
imgid = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select status from ancety where id = {imgid}")
stat = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
counta=cur.fetchone()[0]
con.commit()
if imgid>counta:
imgid=1
while stat ==0 :
imgid+=1
if imgid>counta:
imgid=1
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select status from ancety where id = {imgid}")
stat = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select mainphoto from ancety where id = {imgid}")
img = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select name from ancety where id = {imgid}")
aname = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select cena from ancety where id = {imgid}")
acena = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select about from ancety where id = {imgid}")
aabout = cur.fetchone()[0]
con.commit()
texttext = f"❣️Анкета №{imgid}\n\n💁♀️Имя: {aname}\n\n💰Цена за час: {acena}\n\n🧚♀️О себе: {aabout}"
imglink=f"images/{img}"
photo = open(imglink, 'rb')
bot.send_photo(message.chat.id, photo, caption=texttext, reply_markup=keyboard)
except Exception as e:
raise
elif message.text == b2:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select balance from users where id = {message.chat.id}")
bn=cur.fetchone()[0]
con.commit()
bot.send_message(message.chat.id,f"Ваш баланс {bn} RUB",reply_markup=bal())
bot.register_next_step_handler(message, balik)
elif message.text == b3:
bot.send_message(message.chat.id,"🔑Напишите свой промокод",reply_markup=cancel())
bot.register_next_step_handler(message, promo)
elif message.text == b4:
bot.send_message(message.chat.id,b4)
elif message.text == b11:
bot.send_message(message.chat.id,a11,reply_markup=userpanel())
elif message.text == vxodadmin and message.chat.id == admin:
adm = types.InlineKeyboardMarkup()
adm1 = types.InlineKeyboardButton(text=b4, callback_data="qiwi")
adm2 = types.InlineKeyboardButton(text=b5, callback_data="stat")
adm3 = types.InlineKeyboardButton(text=b6, callback_data="send")
adm4 = types.InlineKeyboardButton(text=b9, callback_data="addancete")
adm7 = types.InlineKeyboardButton(text=b22, callback_data="addphoto")
adm5 = types.InlineKeyboardButton(text=b10, callback_data="deleteancete")
adm6 = types.InlineKeyboardButton(text=b7, callback_data="esc")
adm.add(adm1)
adm.add(adm2)
adm.add(adm3)
adm.add(adm4)
adm.add(adm7)
adm.add(adm5)
adm.add(adm6)
bot.send_message(message.chat.id,"Админ панель⚙️",reply_markup=adm)
elif message.text == vxodworker:
wrk = types.InlineKeyboardMarkup()
wrk1 = types.InlineKeyboardButton(text=b8, callback_data="ref")
wrk2 = types.InlineKeyboardButton(text=b18, callback_data="prom")
wrk4 = types.InlineKeyboardButton(text=b5, callback_data="statw")
wrk3 = types.InlineKeyboardButton(text=b11, callback_data="menu")
wrk.add(wrk1)
wrk.add(wrk2)
wrk.add(wrk4)
wrk.add(wrk3)
bot.send_message(message.chat.id,"Воркер панель⚙️",reply_markup=wrk)
elif message.text == b19:
bot.send_message(message.chat.id,a19)
elif message.text == b20:
bot.send_message(message.chat.id,"Отменено",reply_markup=userpanel())
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
keyboard = types.InlineKeyboardMarkup()
q1 = types.InlineKeyboardButton(text=b14, callback_data="vybor")
q2 = types.InlineKeyboardButton(text=b15, callback_data="photos")
q3 = types.InlineKeyboardButton(text=b16, callback_data="prew")
q4 = types.InlineKeyboardButton(text=b17, callback_data="next")
keyboard.add(q1,q2)
keyboard.add(q3,q4)
if call.message:
if call.data == "next":
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select photoid from users where id = {call.message.chat.id}")
imgid = cur.fetchone()[0]
con.commit()
imgid +=1
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
counta=cur.fetchone()[0]
con.commit()
if imgid>counta:
imgid=1
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select status from ancety where id = {imgid}")
stat = cur.fetchone()[0]
con.commit()
while stat ==0 :
imgid+=1
if imgid>counta:
imgid=1
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select status from ancety where id = {imgid}")
stat = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE users SET photoid = {imgid} WHERE id = {call.message.chat.id}")
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select mainphoto from ancety where id = {imgid}")
img = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select name from ancety where id = {imgid}")
aname = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select cena from ancety where id = {imgid}")
acena = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select about from ancety where id = {imgid}")
aabout = cur.fetchone()[0]
con.commit()
texttext = f"❣️Анкета №{imgid}\n\n💁♀️Имя: {aname}\n\n💰Цена за час: {acena}\n\n🧚♀️О себе: {aabout}"
imglink=f"images/{img}"
photo = open(imglink, 'rb')
bot.edit_message_media(chat_id=call.message.chat.id, message_id=call.message.message_id, media=types.InputMediaPhoto(photo), reply_markup=keyboard)
bot.edit_message_caption(chat_id=call.message.chat.id, message_id=call.message.message_id, caption=texttext, reply_markup=keyboard)
elif call.data == "prew":
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select photoid from users where id = {call.message.chat.id}")
imgid = cur.fetchone()[0]
con.commit()
imgid -=1
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
counta=cur.fetchone()[0]
con.commit()
if imgid<1:
imgid=counta
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select status from ancety where id = {imgid}")
stat = cur.fetchone()[0]
con.commit()
while stat ==0 :
imgid-=1
if imgid<1:
imgid=counta
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select status from ancety where id = {imgid}")
stat = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE users SET photoid = {imgid} WHERE id = {call.message.chat.id}")
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select mainphoto from ancety where id = {imgid}")
img = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select name from ancety where id = {imgid}")
aname = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select cena from ancety where id = {imgid}")
acena = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select about from ancety where id = {imgid}")
aabout = cur.fetchone()[0]
con.commit()
texttext = f"❣️Анкета №{imgid}\n\n💁♀️Имя: {aname}\n\n💰Цена за час: {acena}\n\n🧚♀️О себе: {aabout}"
imglink=f"images/{img}"
photo = open(imglink, 'rb')
bot.edit_message_media(chat_id=call.message.chat.id, message_id=call.message.message_id, media=types.InputMediaPhoto(photo), reply_markup=keyboard)
bot.edit_message_caption(chat_id=call.message.chat.id, message_id=call.message.message_id, caption=texttext, reply_markup=keyboard)
elif call.data == "addancete":
bot.send_message(call.message.chat.id, "Отправьте главное фото анкеты")
bot.register_next_step_handler(call.message, newancet)
elif call.data == "menu":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,text ="Воркер панель закрыта")
elif call.data == "prom":
bot.send_message(call.message.chat.id, "Напишите на какую сумму создать промокод.")
bot.register_next_step_handler(call.message, create_promo)
elif call.data == "esc":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,text ="Админ панель закрыта")
elif call.data == "deleteancete":
bot.send_message(call.message.chat.id, "Введите номер анкеты который хотите удалить",reply_markup=cancel())
bot.register_next_step_handler(call.message, otklancete)
elif call.data == "prov":
user_id = call.message.chat.id
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select num from qiwi")
qiwinumber = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select token from qiwi")
token_qiwi = cur.fetchone()[0]
con.commit()
QIWI_TOKEN = token_qiwi
QIWI_ACCOUNT = str(qiwinumber)
s = requests.Session()
s.headers['authorization'] = 'Bearer ' + QIWI_TOKEN
parameters = {'rows': '50'}
h = s.get('https://edge.qiwi.com/payment-history/v1/persons/' + QIWI_ACCOUNT + '/payments',params=parameters)
req = json.loads(h.text)
try:
cur.execute(f"SELECT * FROM oplata WHERE id = {user_id}")
result = cur.fetchone()
comment = str(result[1])
for x in range(len(req['data'])):
if req['data'][x]['comment'] == comment:
skolko = (req['data'][x]['sum']['amount'])
cur.execute(f"DELETE FROM oplata WHERE id = {user_id}")
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select balance from users WHERE id = {call.message.chat.id}")
balancenow = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE users SET balance = {balancenow+skolko} WHERE id = {call.message.chat.id}")
con.commit()
cur.execute(f"SELECT boss FROM users WHERE id = {user_id}")
for worker in cur.execute(f"SELECT boss FROM users WHERE id = {user_id}"):
wk = worker[0]
cur.execute(f"SELECT username FROM users WHERE id = {wk}")
for username in cur.execute(f"SELECT username FROM users WHERE id = {wk}"):
workerusername = username[0]
for name in cur.execute(f"SELECT name FROM users WHERE id = {wk}"):
workername = name[0]
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select name from users where id = {call.message.chat.id}")
mamont = cur.fetchone()[0]
con.commit()
bot.send_message(zalety,f"💕 Успешное пополнение 💕\n\n💰 Сумма {skolko}р\n\n🦹🏻♀️ Воркер @{workerusername} ({workername})\n\n🐘Мамонт {mamont}")
bot.send_message(call.message.chat.id,f"Ваш баланс пополнен.\n\nБаланс {balancenow+skolko} RUB",reply_markup=userpanel())
break
else:
bot.send_message(call.message.chat.id,"⚠️Вы не оплатили⚠️\n\nОплатите заказ после чего нажмите \"Проверить оплату\"")
break
except:
pass
elif call.data == "stat":
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"SELECT COUNT (*) FROM users")
number = cur.fetchone()[0]
con.commit()
bot.send_message(call.message.chat.id, f"Всего пользователей в боте - {number}")
elif call.data == "vkl":
try:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
c=cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE ancety SET status = {1} WHERE id = {c}")
con.commit()
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,text ="Анкета включена")
except Exception as e:
raise
elif call.data == "otkl":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,text ="Анкета отключена")
bot.register_next_step_handler(call.message, main_message)
elif call.data == "ref":
reflnk=f"http://t.me/{bot_username}?start={call.message.chat.id}"
otvet_ref = f"Ваша реф ссылка {reflnk}"
bot.send_message(call.message.chat.id,otvet_ref)
elif call.data == "qiwi":
bot.send_message(call.message.chat.id,"Отправьте номер кошелька(без + а) и токен в формате номер:токен\n\nПример 7916123456:s132sdfsdf21s5f6sdf1s3s3dfs132",reply_markup=cancel())
bot.register_next_step_handler(call.message,replaceqiwi)
elif call.data == "send":
bot.send_message(call.message.chat.id,"Напишите текст для расылки",reply_markup=cancel())
bot.register_next_step_handler(call.message,rass)
elif call.data == "vybor":
bot.send_message(call.message.chat.id,skolkochasov,reply_markup=cancel())
bot.register_next_step_handler(call.message,chas)
elif call.data == "addphoto":
bot.send_message(call.message.chat.id,"Напишите номер анкеты к которому хотите добавить фотографии",reply_markup=cancel())
bot.register_next_step_handler(call.message,addp)
elif call.data == "photos":
# try:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"SELECT photoid from users where id = {call.message.chat.id}")
pi = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from photos where anceta = {pi}")
allp = cur.fetchone()[0]
con.commit()
if allp == 0:
bot.send_message(call.message.chat.id,"Больше фотографии нету.")
else:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"SELECT image FROM photos where anceta = {pi}")
id = cur.fetchall()
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"SELECT mainphoto FROM ancety where id = {pi}")
mi=f"images/{cur.fetchone()[0]}"
con.commit()
mip = open(mi, 'rb')
bot.edit_message_media(chat_id=call.message.chat.id, message_id=call.message.message_id,media=types.InputMediaPhoto(mip))
for i in id:
try:
imglink=f"images/{i[0]}"
photo = open(imglink, 'rb')
bot.send_photo(call.message.chat.id, photo)
time.sleep(0.1)
except:
pass
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select mainphoto from ancety where id = {pi}")
img = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select name from ancety where id = {pi}")
aname = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select cena from ancety where id = {pi}")
acena = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select about from ancety where id = {pi}")
aabout = cur.fetchone()[0]
con.commit()
texttext = f"❣️Анкета №{pi}\n\n💁♀️Имя: {aname}\n\n💰Цена за час: {acena}\n\n🧚♀️О себе: {aabout}"
imglink=f"images/{img}"
photo = open(imglink, 'rb')
bot.send_photo(call.message.chat.id, photo, caption=texttext, reply_markup=keyboard)
# except Exception as e:
# bot.send_message(call.message.chat.id, e)
elif call.data == "statw":
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from users where boss = {call.message.chat.id}")
wref = cur.fetchone()[0]
con.commit()
bot.send_message(call.message.chat.id, f"У вас {wref} рефералов")
else:
pass
@bot.message_handler(content_types=['photo'])
def newancet(message):
try:
file_info = bot.get_file(message.photo[len(message.photo)-1].file_id)
downloaded_file = bot.download_file(file_info.file_path)
src='images/'+file_info.file_path;
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
imglink=file_info.file_path
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
c=cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
nn="a"
mm = 0
cur.execute(f"INSERT INTO ancety (id,mainphoto,name,cena,about,status)"
f"VALUES ({c+1},\"{imglink}\",\"{nn}\",{mm},\"{nn}\",{0})")
con.commit()
bot.send_message(message.chat.id,"Фото добавлено\n\nКак будем называть эту бабочку?🙃")
bot.register_next_step_handler(message, nameancet)
except Exception as e:
bot.reply_to(message,e)
@bot.message_handler(content_types="text")
def nameancet(message):
try:
nameb = message.text
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
c=cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE ancety SET name = \'{nameb}\' WHERE id = {c}")
con.commit()
bot.send_message(message.chat.id,"Имя выбрано ✅\nВведите цену бабочки за час 💸")
bot.register_next_step_handler(message, cenaancet)
except Exception as e:
bot.reply_to(message,e)
bot.register_next_step_handler(message, nameancet)
@bot.message_handler(content_types="text")
def cenaancet(message):
try:
if message.text.isdigit():
cenna = int(message.text)
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
c=cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE ancety SET cena = {cenna} WHERE id = {c}")
con.commit()
bot.send_message(message.chat.id,"Цена выбрана ✅\nВведите услуги девушки")
bot.register_next_step_handler(message, uslugiancet)
else:
bot.send_message(message.chat.id,"Введите число")
bot.register_next_step_handler(message, cenaancet)
except Exception as e:
bot.reply_to(message,e)
bot.register_next_step_handler(message, cenaancet)
@bot.message_handler(content_types="text")
def uslugiancet(message):
try:
uslu = message.text
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety")
c=cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE ancety SET about = \'{uslu}\' WHERE id = {c}")
con.commit()
ak = types.InlineKeyboardMarkup()
ak1 = types.InlineKeyboardButton(text="Включить", callback_data="vkl")
ak2 = types.InlineKeyboardButton(text="Удалить", callback_data="otkl")
ak.add(ak1)
ak.add(ak2)
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select mainphoto from ancety where id = {c}")
img = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select name from ancety where id = {c}")
aname = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select cena from ancety where id = {c}")
acena = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select about from ancety where id = {c}")
aabout = cur.fetchone()[0]
con.commit()
texttext = f"❣️Анкета №{c}\n\n💁♀️Имя: {aname}\n\n💰Цена за час: {acena}\n\n🧚♀️О себе: {aabout}"
imglink=f"images/{img}"
photo = open(imglink, 'rb')
bot.send_photo(message.chat.id, photo, caption=texttext)
bot.send_message(message.chat.id,"Анкета готова !\nВключить данную анкету ?",reply_markup=ak)
bot.register_next_step_handler(message, main_message)
except Exception as e:
bot.reply_to(message,e)
bot.register_next_step_handler(message, uslugiancet)
@bot.message_handler(content_types="text")
def otklancete(message):
try:
nomer = message.text
if message.text == b20:
bot.send_message(message.chat.id,"Отменено",reply_markup=userpanel())
bot.register_next_step_handler(message, main_message)
else:
if nomer.isdigit():
try:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from ancety where id = {nomer}")
if cur.fetchone()[0] == 1:
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE ancety SET status = {0} WHERE id ={nomer}")
con.commit()
bot.send_message(message.chat.id,"Анкета отключена",reply_markup=userpanel())
bot.register_next_step_handler(message, main_message)
else:
bot.send_message(message.chat.id,"Анкета не найдена\nВведите правильный номер анкеты")
bot.register_next_step_handler(message, otklancete)
except Exception as e:
bot.reply_to(message,e)
bot.register_next_step_handler(message, otklancet)
else:
bot.send_message(message.chat.id,"Введите число")
bot.register_next_step_handler(message, otklancet)
except Exception as e:
bot.reply_to(message,e)
bot.register_next_step_handler(message, otklancet)
@bot.message_handler(content_types="text")
def create_promo(message):
try:
if message.text.isdigit():
summ = int(message.text)
if summ>maxpromo:
bot.send_message(message.chat.id,f"Максимальная сумма промокода {maxpromo}")
bot.register_next_step_handler(message, create_promo)
elif summ<=0:
bot.send_message(message.chat.id,f"Сумма должна быть больше 0")
bot.register_next_step_handler(message, create_promo)
else:
letters = string.ascii_letters
codecode = ( ''.join(random.choice(letters) for i in range(10)) )
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"INSERT INTO promocode (summa,code)"
f"VALUES ({summ},\'{codecode}\')")
con.commit()
bot.send_message(message.chat.id,f"Промокод добавлен !\n\n`{codecode}`\n\nНажмите на промокод чтобы скопировать",parse_mode='Markdown')
bot.register_next_step_handler(message, main_message)
else:
bot.send_message(message.chat.id,"Введите число")
except Exception as e:
bot.reply_to(message,e)
bot.register_next_step_handler(message, create_promo)
@bot.message_handler(content_types="text")
def promo(message):
try:
testpromo = message.text
if testpromo == b20:
bot.send_message(message.chat.id,"Отменено",reply_markup=userpanel())
bot.register_next_step_handler(message, main_message)
else:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select count(*) from promocode where code = \'{testpromo}\'")
r = cur.fetchone()[0]
con.commit()
if r == 0:
bot.send_message(message.chat.id,"Промокод неправильный или уже использовался\n\nНапишите новый промокод.")
bot.register_next_step_handler(message, promo)
else:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select summa from promocode where code = \'{testpromo}\'")
summpromo = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"DELETE from promocode where code = \'{testpromo}\'")
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select balance from users where id = {message.chat.id}")
balancenow = cur.fetchone()[0]
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"UPDATE users SET balance = {balancenow+summpromo} WHERE id = {message.chat.id}")
con.commit()
bot.send_message(message.chat.id,f"♻️Ваш баланс пополнен на {summpromo}\n\n💰Баланс {balancenow+summpromo} RUB",reply_markup=userpanel())
bot.register_next_step_handler(message, main_message)
except Exception as e:
pass
@bot.message_handler(content_types="text")
def balik(message):
if message.text == b12:
bot.send_message(message.chat.id,"Напишите сумму которую хотите пополнить",reply_markup=cancel())
bot.register_next_step_handler(message, popolni)
elif message.text == b20:
bot.send_message(message.chat.id,"Вы вернулись в главное меню",reply_markup=userpanel())
bot.register_next_step_handler(message, main_message)
@bot.message_handler(content_types="text")
def popolni(message):
if message.text == b20:
bot.send_message(message.chat.id,"Вы вернулись в главное меню",reply_markup=userpanel())
bot.register_next_step_handler(message, main_message)
else:
if message.text.isdigit():
skolko = int(message.text)
if skolko >= minimalka and skolko <=maximalka:
try:
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"DELETE FROM oplata WHERE id = {message.chat.id}")
con.commit()
except Exception as e:
raise
con = sqlite3.connect("data.db")
cur = con.cursor()
comment = randint(10000, 9999999)
cur.execute(f"INSERT INTO oplata (id, code) VALUES({message.chat.id}, {comment})")
con.commit()
con = sqlite3.connect("data.db")
cur = con.cursor()
cur.execute(f"select num from qiwi")
qiwinumber = cur.fetchone()[0]
con.commit()
texttt = f'♻️Переведите {skolko}₽ на счет Qiwi\n\nНомер: `{qiwinumber}`\nКомментарий `{comment}`\n\n_Нажмите на номер и комментарий, чтобы их скопировать_'
link = f"https://qiwi.com/payment/form/99?extra%5B%27account%27%5D={qiwinumber}&amountInteger={skolko}&amountFraction=0¤cy=643&extra%5B%27comment%27%5D={comment}&blocked[0]=sum&blocked[1]=account&blocked[2]=comment"
markup_inline = types.InlineKeyboardMarkup()
pereyti = types.InlineKeyboardButton(text="Оплатить картой", callback_data="site", url=link)
proverka = types.InlineKeyboardButton(text='Проверить оплату' ,callback_data='prov')
markup_inline.add(pereyti)
markup_inline.add(proverka)
bot.send_message(message.from_user.id,texttt,parse_mode='Markdown',reply_markup=markup_inline)
bot.register_next_step_handler(message, main_message)
else: