Commit
·
82701a5
1
Parent(s):
4797387
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,15 +36,11 @@ async def main():
|
|
| 36 |
chat_id = chat.id
|
| 37 |
text = event.raw_text
|
| 38 |
|
| 39 |
-
# Timekeeping
|
| 40 |
-
checkpoint = datetime.datetime.now()
|
| 41 |
-
print(f'Checkpoint: {checkpoint}')
|
| 42 |
-
|
| 43 |
# Personal message
|
| 44 |
if chat_id == sender_id:
|
| 45 |
# Check the last reply to this sender
|
| 46 |
last_reply_time = reply_times.get(str(sender_id), None)
|
| 47 |
-
if last_reply_time is None or time.time() - last_reply_time > 60*
|
| 48 |
response = f'Hello {sender_name}, I received your message and will reply as soon as possible. Thank you for your understanding.'
|
| 49 |
await client.send_message(chat_id, response)
|
| 50 |
reply_times[str(sender_id)] = time.time() # update the last reply time
|
|
@@ -52,21 +48,18 @@ async def main():
|
|
| 52 |
# Group message
|
| 53 |
elif '@Mohammed_Alakhras' in text:
|
| 54 |
last_reply_time = reply_times.get(str(str(chat_id)+str(sender_id)), None)
|
| 55 |
-
if last_reply_time is None or time.time() - last_reply_time > 60*
|
| 56 |
-
response = f'Hello {sender_name}@{chat}, I received your message and will reply as soon as possible. Thank you for your understanding.'
|
| 57 |
await client.send_message(chat_id, response)
|
| 58 |
reply_times[str(str(chat_id)+str(sender_id))] = time.time()
|
| 59 |
|
| 60 |
|
| 61 |
await client.run_until_disconnected()
|
| 62 |
-
# client.loop.run_until_complete(main())
|
| 63 |
|
| 64 |
-
# تعريف حقول النص في Gradio
|
| 65 |
|
| 66 |
-
#
|
| 67 |
inputs = []
|
| 68 |
output = "text"
|
| 69 |
gr.Interface(fn=main, inputs=inputs, outputs=output).launch()
|
| 70 |
|
| 71 |
-
# Run the main function in the event loop
|
| 72 |
# client.loop.run_until_complete(main())
|
|
|
|
| 36 |
chat_id = chat.id
|
| 37 |
text = event.raw_text
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
# Personal message
|
| 40 |
if chat_id == sender_id:
|
| 41 |
# Check the last reply to this sender
|
| 42 |
last_reply_time = reply_times.get(str(sender_id), None)
|
| 43 |
+
if last_reply_time is None or time.time() - last_reply_time > 60*60: # reply only if not replied in the last minute
|
| 44 |
response = f'Hello {sender_name}, I received your message and will reply as soon as possible. Thank you for your understanding.'
|
| 45 |
await client.send_message(chat_id, response)
|
| 46 |
reply_times[str(sender_id)] = time.time() # update the last reply time
|
|
|
|
| 48 |
# Group message
|
| 49 |
elif '@Mohammed_Alakhras' in text:
|
| 50 |
last_reply_time = reply_times.get(str(str(chat_id)+str(sender_id)), None)
|
| 51 |
+
if last_reply_time is None or time.time() - last_reply_time > 60*5:
|
| 52 |
+
response = f'Hello {sender_name}@{chat.title}, I received your message and will reply as soon as possible. Thank you for your understanding.'
|
| 53 |
await client.send_message(chat_id, response)
|
| 54 |
reply_times[str(str(chat_id)+str(sender_id))] = time.time()
|
| 55 |
|
| 56 |
|
| 57 |
await client.run_until_disconnected()
|
|
|
|
| 58 |
|
|
|
|
| 59 |
|
| 60 |
+
# Gradio Inteface
|
| 61 |
inputs = []
|
| 62 |
output = "text"
|
| 63 |
gr.Interface(fn=main, inputs=inputs, outputs=output).launch()
|
| 64 |
|
|
|
|
| 65 |
# client.loop.run_until_complete(main())
|