zarox commited on
Commit
0a0eb88
·
1 Parent(s): 4cb0ebf
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -140,6 +140,7 @@ client = TelegramClient('session_name', API_ID, API_HASH)
140
  # Define the states for user interaction
141
  states = {}
142
 
 
143
  async def start_handler(event):
144
  await event.reply("Welcome to AudioFusion Bot! Send me an audio file, and I'll apply effects for you.")
145
 
@@ -151,6 +152,7 @@ buttons = [
151
  [Button.inline('Send', b'send')],
152
  ]
153
 
 
154
  async def buttons_handler(event):
155
  user_id = event.sender_id
156
 
@@ -170,6 +172,7 @@ async def buttons_handler(event):
170
  await client.send_file(event.chat_id, file="image.jpg", caption="Preview the current modification:", buttons=buttons)
171
 
172
 
 
173
  async def audio_effect_handler(event):
174
  user_id = event.sender_id
175
  if user_id not in states or not states[user_id]:
@@ -207,6 +210,7 @@ async def audio_effect_handler(event):
207
  await event.reply(f"An error occurred: {str(e)}")
208
 
209
 
 
210
  async def preview_handler(event):
211
  user_id = event.sender_id
212
  if user_id in states and states[user_id]:
@@ -223,6 +227,7 @@ async def preview_handler(event):
223
  await event.answer("No modified audio file found. Please apply an effect first.")
224
 
225
 
 
226
  async def send_handler(event):
227
  user_id = event.sender_id
228
  if user_id in states and states[user_id]:
@@ -240,12 +245,6 @@ async def send_handler(event):
240
 
241
 
242
 
243
- # Register command and button handlers
244
- client.on(events.NewMessage(pattern='/start')(start_handler))
245
- client.on(events.NewMessage(pattern='/buttons')(buttons_handler))
246
- client.on(events.CallbackQuery(pattern=b'(slowed|8d|reverb|reverse|trim|volume|speedup)')(audio_effect_handler))
247
- client.on(events.CallbackQuery(pattern=b'preview')(preview_handler))
248
- client.on(events.CallbackQuery(pattern=b'send')(send_handler))
249
 
250
  async def initiation():
251
  await client.send_message(-1001662130485, "**Hugging is Running.**", buttons=[(Button.url("Execal", "https://t.me/execal"),)],)
 
140
  # Define the states for user interaction
141
  states = {}
142
 
143
+ @client.on(events.NewMessage(pattern='/start'))
144
  async def start_handler(event):
145
  await event.reply("Welcome to AudioFusion Bot! Send me an audio file, and I'll apply effects for you.")
146
 
 
152
  [Button.inline('Send', b'send')],
153
  ]
154
 
155
+ @client.on(events.NewMessage(pattern='/buttons'))
156
  async def buttons_handler(event):
157
  user_id = event.sender_id
158
 
 
172
  await client.send_file(event.chat_id, file="image.jpg", caption="Preview the current modification:", buttons=buttons)
173
 
174
 
175
+ @client.on(events.CallbackQuery(pattern=b'(slowed|8d|reverb|reverse|trim|volume|speedup)'))
176
  async def audio_effect_handler(event):
177
  user_id = event.sender_id
178
  if user_id not in states or not states[user_id]:
 
210
  await event.reply(f"An error occurred: {str(e)}")
211
 
212
 
213
+ @client.on(events.CallbackQuery(pattern=b'preview'))
214
  async def preview_handler(event):
215
  user_id = event.sender_id
216
  if user_id in states and states[user_id]:
 
227
  await event.answer("No modified audio file found. Please apply an effect first.")
228
 
229
 
230
+ @client.on(events.CallbackQuery(pattern=b'send'))
231
  async def send_handler(event):
232
  user_id = event.sender_id
233
  if user_id in states and states[user_id]:
 
245
 
246
 
247
 
 
 
 
 
 
 
248
 
249
  async def initiation():
250
  await client.send_message(-1001662130485, "**Hugging is Running.**", buttons=[(Button.url("Execal", "https://t.me/execal"),)],)