assoum-bot commited on
Commit
3083572
·
verified ·
1 Parent(s): e3c2eaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -11
app.py CHANGED
@@ -1,19 +1,41 @@
1
  import gradio as gr
2
 
3
- def bot_logic(user_channel, user_command, user_response):
4
- return f"🚀 [Bot Assoum] متصل الآن بقناة: {user_channel}\nسيقوم بالرد على '{user_command}' بـ '{user_response}'"
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
7
- gr.Markdown("# 🤖 لوحة تحكم مشتركين [Bot Assoum]")
 
8
 
9
- with gr.Group():
10
- user_channel = gr.Textbox(label="معرف قناتك (مثل @username)", placeholder="أدخل معرف قناتك هنا...")
11
- user_command = gr.Textbox(label="الأمر (مثلاً: !قوانين)", placeholder="اكتب الكلمة هنا...")
12
- user_response = gr.Textbox(label="رد البوت", placeholder="اكتب الرد الذي سيظهر للمتابعين...")
13
-
14
- start_btn = gr.Button("تفعيل البوت في قناتي", variant="primary")
15
- status_out = gr.Textbox(label="حالة البوت")
 
 
 
 
 
 
16
 
17
- start_btn.click(fn=bot_logic, inputs=[user_channel, user_command, user_response], outputs=status_out)
 
18
 
19
  demo.launch()
 
 
1
  import gradio as gr
2
 
3
+ # مخزن الأوامر (هذا هو عقل البوت الذي يحفظ ردودك)
4
+ commands_dict = {}
5
+
6
+ def add_command(cmd, resp):
7
+ if cmd and resp:
8
+ commands_dict[cmd] = resp
9
+ # عرض القائمة المحدثة للمستخدم
10
+ all_cmds = "\n".join([f"{k} -> {v}" for k, v in commands_dict.items()])
11
+ return f"✅ تم إضافة الأمر بنجاح!\n\nالقائمة الحالية:\n{all_cmds}"
12
+ return "❌ يرجى إدخال الأمر والرد."
13
+
14
+ def start_bot(channel_id):
15
+ if channel_id:
16
+ return f"🚀 [Bot Assoum] متصل الآن بالقناة: {channel_id}\nيتم مراقبة {len(commands_dict)} أمر حالياً."
17
+ return "❌ يرجى إدخال معرف القناة."
18
 
19
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
20
+ gr.Markdown("# 🤖 لوحة تحكم [Bot Assoum] المطورة")
21
+ gr.Markdown("هنا يمكنك إضافة مئات الأوامر والردود كما في نايت بوت!")
22
 
23
+ with gr.Row():
24
+ with gr.Column():
25
+ gr.Markdown("### 1. إعدادات القناة")
26
+ channel = gr.Textbox(label="معرف القناة (@username)", placeholder="@gloomy_darkness")
27
+ connect_btn = gr.Button("تفعيل البوت في القناة", variant="primary")
28
+
29
+ with gr.Column():
30
+ gr.Markdown("### 2. إضافة أوامر جديدة")
31
+ cmd_input = gr.Textbox(label="الأمر (مثل !قوانين)")
32
+ resp_input = gr.Textbox(label="الرد (مثل ممنوع السب نورتنا)")
33
+ add_btn = gr.Button("أضف الأمر للقائمة")
34
+
35
+ status = gr.Textbox(label="حالة البوت والأوامر المضافة", lines=5)
36
 
37
+ add_btn.click(fn=add_command, inputs=[cmd_input, resp_input], outputs=status)
38
+ connect_btn.click(fn=start_bot, inputs=channel, outputs=status)
39
 
40
  demo.launch()
41
+