forked from Armanidrisi/python-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
337 lines (306 loc) · 14.2 KB
/
main.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
import time
import json
import telebot
##TOKEN DETAILS
TOKEN = "TRON"
BOT_TOKEN = "6158242764:AAH7Ynhh-_Vartl_5NZksXFPI_9QSYzfw-w"
PAYMENT_CHANNEL = "@purpleebots" #add payment channel here including the '@' sign
OWNER_ID = 2034654684 #write owner's user id here.. get it from @MissRose_Bot by /id
CHANNELS = ["@purpleebots"] #add channels to be checked here in the format - ["Channel 1", "Channel 2"]
#you can add as many channels here and also add the '@' sign before channel username
Daily_bonus = 1 #Put daily bonus amount here!
Mini_Withdraw = 0.5 #remove 0 and add the minimum withdraw u want to set
Per_Refer = 0.0001 #add per refer bonus here
bot = telebot.TeleBot(BOT_TOKEN)
def check(id):
for i in CHANNELS:
check = bot.get_chat_member(i, id)
if check.status != 'left':
pass
else:
return False
return True
bonus = {}
def menu(id):
keyboard = telebot.types.ReplyKeyboardMarkup(True)
keyboard.row('🆔 Account')
keyboard.row('🙌🏻 Referrals', '🎁 Bonus', '💸 Withdraw')
keyboard.row('⚙️ Set Wallet', '📊Statistics')
bot.send_message(id, "*🏡 Home*", parse_mode="Markdown",
reply_markup=keyboard)
@bot.message_handler(commands=['start'])
def start(message):
try:
user = message.chat.id
msg = message.text
if msg == '/start':
user = str(user)
data = json.load(open('users.json', 'r'))
if user not in data['referred']:
data['referred'][user] = 0
data['total'] = data['total'] + 1
if user not in data['referby']:
data['referby'][user] = user
if user not in data['checkin']:
data['checkin'][user] = 0
if user not in data['DailyQuiz']:
data['DailyQuiz'][user] = "0"
if user not in data['balance']:
data['balance'][user] = 0
if user not in data['wallet']:
data['wallet'][user] = "none"
if user not in data['withd']:
data['withd'][user] = 0
if user not in data['id']:
data['id'][user] = data['total']+1
json.dump(data, open('users.json', 'w'))
print(data)
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(
text='🤼♂️ Joined', callback_data='check'))
msg_start = "*🍔 To Use This Bot You Need To Join This Channel - "
for i in CHANNELS:
msg_start += f"\n➡️ {i}\n"
msg_start += "*"
bot.send_message(user, msg_start,
parse_mode="Markdown", reply_markup=markup)
else:
data = json.load(open('users.json', 'r'))
user = message.chat.id
user = str(user)
refid = message.text.split()[1]
if user not in data['referred']:
data['referred'][user] = 0
data['total'] = data['total'] + 1
if user not in data['referby']:
data['referby'][user] = refid
if user not in data['checkin']:
data['checkin'][user] = 0
if user not in data['DailyQuiz']:
data['DailyQuiz'][user] = 0
if user not in data['balance']:
data['balance'][user] = 0
if user not in data['wallet']:
data['wallet'][user] = "none"
if user not in data['withd']:
data['withd'][user] = 0
if user not in data['id']:
data['id'][user] = data['total']+1
json.dump(data, open('users.json', 'w'))
print(data)
markups = telebot.types.InlineKeyboardMarkup()
markups.add(telebot.types.InlineKeyboardButton(
text='🤼♂️ Joined', callback_data='check'))
msg_start = "*🍔 To Use This Bot You Need To Join This Channel - \n➡️ @ Fill your channels at line: 101 and 157*"
bot.send_message(user, msg_start,
parse_mode="Markdown", reply_markup=markups)
except:
bot.send_message(message.chat.id, "This command having error pls wait for ficing the glitch by admin")
bot.send_message(OWNER_ID, "Your bot got an error fix it fast!\n Error on command: "+message.text)
return
@bot.callback_query_handler(func=lambda call: True)
def query_handler(call):
try:
ch = check(call.message.chat.id)
if call.data == 'check':
if ch == True:
data = json.load(open('users.json', 'r'))
user_id = call.message.chat.id
user = str(user_id)
bot.answer_callback_query(
callback_query_id=call.id, text='✅ You joined Now yu can earn money')
bot.delete_message(call.message.chat.id, call.message.message_id)
if user not in data['refer']:
data['refer'][user] = True
if user not in data['referby']:
data['referby'][user] = user
json.dump(data, open('users.json', 'w'))
if int(data['referby'][user]) != user_id:
ref_id = data['referby'][user]
ref = str(ref_id)
if ref not in data['balance']:
data['balance'][ref] = 0
if ref not in data['referred']:
data['referred'][ref] = 0
json.dump(data, open('users.json', 'w'))
data['balance'][ref] += Per_Refer
data['referred'][ref] += 1
bot.send_message(
ref_id, f"*🏧 New Referral on Level 1, You Got : +{Per_Refer} {TOKEN}*", parse_mode="Markdown")
json.dump(data, open('users.json', 'w'))
return menu(call.message.chat.id)
else:
json.dump(data, open('users.json', 'w'))
return menu(call.message.chat.id)
else:
json.dump(data, open('users.json', 'w'))
menu(call.message.chat.id)
else:
bot.answer_callback_query(
callback_query_id=call.id, text='❌ You not Joined')
bot.delete_message(call.message.chat.id, call.message.message_id)
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(
text='🤼♂️ Joined', callback_data='check'))
msg_start = "*🍔 To Use This Bot You Need To Join This Channel - \n➡️ @ Fill your channels at line: 101 and 157*"
bot.send_message(call.message.chat.id, msg_start,
parse_mode="Markdown", reply_markup=markup)
except:
bot.send_message(call.message.chat.id, "This command having error pls wait for ficing the glitch by admin")
bot.send_message(OWNER_ID, "Your bot got an error fix it fast!\n Error on command: "+call.data)
return
@bot.message_handler(content_types=['text'])
def send_text(message):
try:
if message.text == '🆔 Account':
data = json.load(open('users.json', 'r'))
accmsg = '*👮 User : {}\n\n⚙️ Wallet : *`{}`*\n\n💸 Balance : *`{}`* {}*'
user_id = message.chat.id
user = str(user_id)
if user not in data['balance']:
data['balance'][user] = 0
if user not in data['wallet']:
data['wallet'][user] = "none"
json.dump(data, open('users.json', 'w'))
balance = data['balance'][user]
wallet = data['wallet'][user]
msg = accmsg.format(message.from_user.first_name,
wallet, balance, TOKEN)
bot.send_message(message.chat.id, msg, parse_mode="Markdown")
if message.text == '🙌🏻 Referrals':
data = json.load(open('users.json', 'r'))
ref_msg = "*⏯️ Total Invites : {} Users\n\n👥 Refferrals System\n\n1 Level:\n🥇 Level°1 - {} {}\n\n🔗 Referral Link ⬇️\n{}*"
bot_name = bot.get_me().username
user_id = message.chat.id
user = str(user_id)
if user not in data['referred']:
data['referred'][user] = 0
json.dump(data, open('users.json', 'w'))
ref_count = data['referred'][user]
ref_link = 'https://telegram.me/{}?start={}'.format(
bot_name, message.chat.id)
msg = ref_msg.format(ref_count, Per_Refer, TOKEN, ref_link)
bot.send_message(message.chat.id, msg, parse_mode="Markdown")
if message.text == "⚙️ Set Wallet":
user_id = message.chat.id
user = str(user_id)
keyboard = telebot.types.ReplyKeyboardMarkup(True)
keyboard.row('🚫 Cancel')
send = bot.send_message(message.chat.id, "_⚠️Send your TRX Wallet Address._",
parse_mode="Markdown", reply_markup=keyboard)
# Next message will call the name_handler function
bot.register_next_step_handler(message, trx_address)
if message.text == "🎁 Bonus":
user_id = message.chat.id
user = str(user_id)
cur_time = int((time.time()))
data = json.load(open('users.json', 'r'))
#bot.send_message(user_id, "*🎁 Bonus Button is Under Maintainance*", parse_mode="Markdown")
if (user_id not in bonus.keys()) or (cur_time - bonus[user_id] > 60*60*24):
data['balance'][(user)] += Daily_bonus
bot.send_message(
user_id, f"Congrats you just received {Daily_bonus} {TOKEN}")
bonus[user_id] = cur_time
json.dump(data, open('users.json', 'w'))
else:
bot.send_message(
message.chat.id, "❌*You can only take bonus once every 24 hours!*",parse_mode="markdown")
return
if message.text == "📊Statistics":
user_id = message.chat.id
user = str(user_id)
data = json.load(open('users.json', 'r'))
msg = "*📊 Total members : {} Users\n\n🥊 Total successful Withdraw : {} {}*"
msg = msg.format(data['total'], data['totalwith'], TOKEN)
bot.send_message(user_id, msg, parse_mode="Markdown")
return
if message.text == "💸 Withdraw":
user_id = message.chat.id
user = str(user_id)
data = json.load(open('users.json', 'r'))
if user not in data['balance']:
data['balance'][user] = 0
if user not in data['wallet']:
data['wallet'][user] = "none"
json.dump(data, open('users.json', 'w'))
bal = data['balance'][user]
wall = data['wallet'][user]
if wall == "none":
bot.send_message(user_id, "_❌ wallet Not set_",
parse_mode="Markdown")
return
if bal >= Mini_Withdraw:
bot.send_message(user_id, "_Enter Your Amount_",
parse_mode="Markdown")
bot.register_next_step_handler(message, amo_with)
else:
bot.send_message(
user_id, f"_❌Your balance low you should have at least {Mini_Withdraw} {TOKEN} to Withdraw_", parse_mode="Markdown")
return
except:
bot.send_message(message.chat.id, "This command having error pls wait for ficing the glitch by admin")
bot.send_message(OWNER_ID, "Your bot got an error fix it fast!\n Error on command: "+message.text)
return
def trx_address(message):
try:
if message.text == "🚫 Cancel":
return menu(message.chat.id)
if len(message.text) == 34:
user_id = message.chat.id
user = str(user_id)
data = json.load(open('users.json', 'r'))
data['wallet'][user] = message.text
bot.send_message(message.chat.id, "*💹Your Trx wallet set to " +
data['wallet'][user]+"*", parse_mode="Markdown")
json.dump(data, open('users.json', 'w'))
return menu(message.chat.id)
else:
bot.send_message(
message.chat.id, "*⚠️ It's Not a Valid Trx Address!*", parse_mode="Markdown")
return menu(message.chat.id)
except:
bot.send_message(message.chat.id, "This command having error pls wait for ficing the glitch by admin")
bot.send_message(OWNER_ID, "Your bot got an error fix it fast!\n Error on command: "+message.text)
return
def amo_with(message):
try:
user_id = message.chat.id
amo = message.text
user = str(user_id)
data = json.load(open('users.json', 'r'))
if user not in data['balance']:
data['balance'][user] = 0
if user not in data['wallet']:
data['wallet'][user] = "none"
json.dump(data, open('users.json', 'w'))
bal = data['balance'][user]
wall = data['wallet'][user]
msg = message.text
if msg.isdigit() == False:
bot.send_message(
user_id, "_📛 Invaild value. Enter only numeric value. Try again_", parse_mode="Markdown")
return
if int(message.text) < Mini_Withdraw:
bot.send_message(
user_id, f"_❌ Minimum withdraw {Mini_Withdraw} {TOKEN}_", parse_mode="Markdown")
return
if int(message.text) > bal:
bot.send_message(
user_id, "_❌ You Can't withdraw More than Your Balance_", parse_mode="Markdown")
return
amo = int(amo)
data['balance'][user] -= int(amo)
data['totalwith'] += int(amo)
bot_name = bot.get_me().username
json.dump(data, open('users.json', 'w'))
bot.send_message(user_id, "✅* Withdraw is request to our owner automatically\n\n💹 Payment Channel :- "+PAYMENT_CHANNEL +"*", parse_mode="Markdown")
markupp = telebot.types.InlineKeyboardMarkup()
markupp.add(telebot.types.InlineKeyboardButton(text='🍀 BOT LINK', url=f'https://telegram.me/{bot_name}?start={OWNER_ID}'))
send = bot.send_message(PAYMENT_CHANNEL, "✅* New Withdraw\n\n⭐ Amount - "+str(amo)+f" {TOKEN}\n🦁 User - @"+message.from_user.username+"\n💠 Wallet* - `"+data['wallet'][user]+"`\n☎️ *User Referrals = "+str(
data['referred'][user])+"\n\n🏖 Bot Link - @"+bot_name+"\n⏩ Please wait our owner will confrim it*", parse_mode="Markdown", disable_web_page_preview=True, reply_markup=markupp)
except:
bot.send_message(message.chat.id, "This command having error pls wait for ficing the glitch by admin")
bot.send_message(OWNER_ID, "Your bot got an error fix it fast!\n Error on command: "+message.text)
return
if __name__ == '__main__':
bot.polling(none_stop=True)