-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
311 lines (266 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
import logging
import re
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
from telegram.constants import ParseMode
from telegram.ext import (
Application, CommandHandler, CallbackQueryHandler,
MessageHandler, filters, ContextTypes, ConversationHandler
)
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
logger = logging.getLogger(__name__)
# Define states for conversation flow
SELECTING_CHAIN, TYPING_TOKEN, TYPING_PORTAL, SELECTING_SLOT, SELECTING_PERIOD, CONFIRMING_ORDER = range(6)
# Prices dictionary
PRICES = {
'Top 3 Guarantee': {
'3 hours': '5.6',
'6 hours': '9.92',
'12 hours': '17.92',
'24 hours': '29.92'
},
'Top 8 Guarantee': {
'3 hours': '4.65',
'6 hours': '8.37',
'12 hours': '14.48',
'24 hours': '25.92'
},
'Any position': {
'3 hours': '3.85',
'6 hours': '6.93',
'12 hours': '12.32',
'24 hours': '21.56'
}
}
# Define a few command handlers. These usually take the two arguments update and context.
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Send a message when the command /start is issued."""
keyboard = [
[InlineKeyboardButton("ETH", callback_data='ETH')],
[InlineKeyboardButton("BNB", callback_data='BNB')],
[InlineKeyboardButton("SOL", callback_data='SOL')]
]
reply_markup = InlineKeyboardMarkup(keyboard)
if update.message:
await update.message.reply_text('Select chain:', reply_markup=reply_markup)
elif update.callback_query:
await update.callback_query.message.reply_text('Select chain:', reply_markup=reply_markup)
return SELECTING_CHAIN
async def button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle button clicks."""
query = update.callback_query
await query.answer()
await query.edit_message_text(text=" Send me token address.")
# Store the chain selection in the context for future use
context.user_data['chain'] = query.data
return TYPING_TOKEN
async def token_address(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle token address input."""
user_address = update.message.text
context.user_data['token_address'] = user_address
# Ask the user what they want to order
order_keyboard = [
[InlineKeyboardButton("Trending Fast-Track", callback_data='Fast-Track')]
]
order_reply_markup = InlineKeyboardMarkup(order_keyboard)
await update.message.reply_text('What do you want to order?', reply_markup=order_reply_markup)
return SELECTING_SLOT
async def order(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle order selection."""
query = update.callback_query
await query.answer()
await query.edit_message_text(text="❔ Send me portal/group link.")
return TYPING_PORTAL
async def portal_group_link(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle portal/group link input."""
portal_link = update.message.text
# Regex pattern to validate a Telegram link
telegram_link_pattern = re.compile(r'(https?://)?(www\.)?(t\.me|telegram\.me)/[a-zA-Z0-9_]+')
if telegram_link_pattern.match(portal_link):
context.user_data['portal_link'] = portal_link
# Ask the user to select an open slot
slot_keyboard = [
[
InlineKeyboardButton("🟢 Top 3 Guarantee", callback_data='Top 3 Guarantee'),
InlineKeyboardButton("🔴 Top 8 Guarantee", callback_data='Top 8 Guarantee')
],
[InlineKeyboardButton("🟢 Any position", callback_data='Any position')]
]
slot_reply_markup = InlineKeyboardMarkup(slot_keyboard)
await update.message.reply_text(
'ℹ Select open slot or click to see the nearest potential availability time:',
reply_markup=slot_reply_markup
)
return SELECTING_SLOT
else:
await update.message.reply_text("❗️ Incorrect portal or group link.")
return TYPING_PORTAL
async def slot_selection(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle slot selection."""
query = update.callback_query
await query.answer()
context.user_data['slot'] = query.data
# Present period options
period_keyboard = [
[
InlineKeyboardButton("3 hours", callback_data='3 hours'),
InlineKeyboardButton("6 hours | -10%", callback_data='6 hours')
],
[
InlineKeyboardButton("12 hours | -20%", callback_data='12 hours'),
InlineKeyboardButton("24 hours | -30%", callback_data='24 hours')
]
]
period_reply_markup = InlineKeyboardMarkup(period_keyboard)
await query.message.reply_text('❔ Select period:', reply_markup=period_reply_markup)
return SELECTING_PERIOD
async def period_selection(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle period selection."""
query = update.callback_query
await query.answer()
context.user_data['period'] = query.data
# Gather all the details for confirmation
token_address = context.user_data.get('token_address')
chain = context.user_data.get('chain')
portal_link = context.user_data.get('portal_link')
slot = context.user_data.get('slot')
period = query.data
price = PRICES[slot][period] # Retrieve the price from the dictionary
# Send confirmation message
confirmation_message = (
f"<b>Confirm your order:</b>\n\n"
f"<b>Token Address:</b> <b>{token_address}</b>\n"
f"<b>Chain:</b> <b>{chain}</b>\n"
f"<b>Portal:</b> <b>{portal_link}</b>\n"
f"<b>Time:</b> <b>{period}</b>\n"
f"<b>Top:</b> <b>{slot}</b>\n"
f"<b>Price:</b> <b>{price} SOL</b>\n\n"
'Be sure to read full message before you continue, by clicking "✅ Confirm" button below you also confirm that you understand and accept rules:\n'
'1. Deluge.Cash team can remove your token from the trending list with no chance of a refund if they suspect a scam in your token (ex.: sell tax 99%, developer mints a lot of tokens, liquidity removal and etc.) or abandoned project or lack of telegram group moderation or false information or deception or NSFW content in group or any place where links in channel/group leads to including "portals" to group.\n'
"2. You must ensure that your advertisement, links to channels or groups you provide and any related materials posted, distributed or linked to in a group or channel you provide do not provide false information, deception, sexual or any NSFW (Not Safe For Work) content. This includes, but is not limited to, any material that is pornographic, sexually explicit, or otherwise inappropriate for a general audience.\n"
"3. You are forbidden from including or linking to pornography, sexually explicit images, videos, or other materials, whether real or simulated, in your advertisement.\n"
"4. You must avoid including sexually suggestive content in your advertisement, including images, videos, text, and any other forms of media intended to arouse.\n"
"5. You must ensure that your advertisement do not involve scams or fraudulent schemes intended to deceive others for financial gain or other benefits.\n"
'6. If suspicious activity in the form of "farming" (developers keeping more than 14%, splitting wallets) is noticed and according to the Deluge.Cash team it may be a threat, your token will be removed from trending list, refund is not available.\n'
"7. You should also realize that the position in the trending list has NO IMPACT on the chances of sending a buy in the trending channel, chances of sending buy to channel: ~25% for buys >10$ if @buybot setted up in group.\n"
"8. For violation of any of the above rules your token will be removed from trending list, refund is not available.\n"
"9. Refund can be made only in case of full service disruption (stop updating trending list and your token not in the list and full stop displaying buys in the channel) more than 20 minutes straight and to the address of the wallet from which the payment was made to the address for payment, do NOT send payment from exchanges or wallets to which you do not have access because you will not be refunded, use only your personal wallet to which you will always have access."
)
confirm_keyboard = [
[InlineKeyboardButton("✅ Confirm", callback_data='confirm_order')],
[InlineKeyboardButton("🔄 Cancel and start over", callback_data='cancel_and_start_over')]
]
confirm_reply_markup = InlineKeyboardMarkup(confirm_keyboard)
await query.edit_message_text(confirmation_message, reply_markup=confirm_reply_markup, parse_mode=ParseMode.HTML)
return CONFIRMING_ORDER
async def cancel_and_start_over(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle cancel and start over."""
query = update.callback_query
await query.answer()
await query.edit_message_text(text="Order cancelled. Starting over.")
return await start(query, context)
async def delete(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
"""Handle /delete command."""
delete_keyboard = [
[InlineKeyboardButton("✅ Yes, I'm sure", callback_data='confirm_delete')],
[InlineKeyboardButton("❗️ No", callback_data='cancel_delete')]
]
delete_reply_markup = InlineKeyboardMarkup(delete_keyboard)
await update.message.reply_text(
'Are you sure to delete all configuration data?\n'
'Do not do this if you have paid or are about to pay for this configuration, '
'as a new payment wallet will be generated next time!',
reply_markup=delete_reply_markup
)
async def confirm_delete(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle confirmation of delete."""
query = update.callback_query
await query.answer()
# Clear user data
context.user_data.clear()
# await query.edit_message_text(text="All configuration data has been deleted. Restarting the bot.")
# Restart the bot
return await start(query, context)
async def cancel_delete(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle cancellation of delete."""
query = update.callback_query
await query.answer()
await query.edit_message_text(text="Deletion cancelled.")
# End the conversation
return ConversationHandler.END
async def confirm_order(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle order confirmation."""
query = update.callback_query
await query.answer()
# Retrieve user-entered data
token_address = context.user_data.get('token_address')
chain = context.user_data.get('chain')
portal_link = context.user_data.get('portal_link')
slot = context.user_data.get('slot')
period = context.user_data.get('period')
price = PRICES[slot][period] # Retrieve the price from the dictionary
payment_information = (
"❔ <b>Payment Information:</b>\n\n"
"⤵️<b> Always double-check that you have entered the correct address before sending.</b>\n"
f"<b>Address:</b> <code>tsouroAdress87826726fgf8</code>\n"
f"<b>Amount:</b> <code>{price}</code><b> SOL</b>\n\n"
"<b>After the transfer, click the button below. You can transfer the rest if you haven't transferred enough.</b>\n\n"
"<b>To cancel the payment and start over, use /delete.</b>"
)
check_payment_keyboard = [
[InlineKeyboardButton("Check payment", callback_data='check_payment')]
]
check_payment_reply_markup = InlineKeyboardMarkup(check_payment_keyboard)
await query.edit_message_text(payment_information, reply_markup=check_payment_reply_markup, parse_mode=ParseMode.HTML)
# Here you can add logic to process the confirmed order.
return ConversationHandler.END
async def check_payment(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
"""Handle check payment."""
query = update.callback_query
await query.answer()
await query.message.reply_text(text="❗️ Payment Not Received.")
return ConversationHandler.END
def main() -> None:
"""Start the bot."""
# Insert your API token here
token = '6712612854:AAGM6qpdti40uBxGxizfXKvtMmTrXeCS2F0'
# Create the Application and pass it your bot's token.
application = Application.builder().token(token).build()
# Define conversation handler with states
conv_handler = ConversationHandler(
entry_points=[CommandHandler("start", start)],
states={
SELECTING_CHAIN: [CallbackQueryHandler(button, pattern='^(ETH|BNB|SOL)$')],
TYPING_TOKEN: [MessageHandler(filters.TEXT & ~filters.COMMAND, token_address)],
TYPING_PORTAL: [MessageHandler(filters.TEXT & ~filters.COMMAND, portal_group_link)],
SELECTING_SLOT: [
CallbackQueryHandler(order, pattern='^(Fast-Track)$'),
CallbackQueryHandler(slot_selection, pattern='^(Top 3 Guarantee|Top 8 Guarantee|Any position)$')
],
SELECTING_PERIOD: [
CallbackQueryHandler(period_selection, pattern='^(3 hours|6 hours|12 hours|24 hours)$')
],
CONFIRMING_ORDER: [
CallbackQueryHandler(confirm_order, pattern='^confirm_order$'),
CallbackQueryHandler(cancel_and_start_over, pattern='^cancel_and_start_over$'),
CallbackQueryHandler(confirm_delete, pattern='^confirm_delete$'),
CallbackQueryHandler(cancel_delete, pattern='^cancel_delete$')
]
},
fallbacks=[CommandHandler("start", start)]
)
# Add conversation handler to application
application.add_handler(conv_handler)
# Add delete command handler
application.add_handler(CommandHandler("delete", delete))
application.add_handler(CallbackQueryHandler(confirm_delete, pattern='^confirm_delete$'))
application.add_handler(CallbackQueryHandler(cancel_delete, pattern='^cancel_delete$'))
# Add check payment handler
application.add_handler(CallbackQueryHandler(check_payment, pattern='^check_payment$'))
# Start the Bot
application.run_polling()
if __name__ == '__main__':
main()