Skip to content
This repository was archived by the owner on Jun 18, 2022. It is now read-only.

Commit 1f50b02

Browse files
committed
[ChatBot] Send message directly instead of replying
1 parent 891f1f8 commit 1f50b02

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

SaitamaRobot/modules/chatbot.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ def add_chat(bot: Bot, update: Update):
3535
ses_id = str(ses.id)
3636
expires = str(ses.expires)
3737
sql.set_ses(chat.id, ses_id, expires)
38-
msg.reply_text("AI successfully enabled for this chat!")
38+
chat.send_message("AI successfully enabled for this chat!")
3939
message = (f"<b>{html.escape(chat.title)}:</b>\n"
4040
f"#AI_ENABLED\n"
4141
f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n")
4242
return message
4343
else:
44-
msg.reply_text("AI is already enabled for this chat!")
45-
return ""
46-
44+
chat.send_message("AI is already enabled for this chat!")
45+
return ""
46+
4747
@run_async
4848
@user_admin
4949
@gloggable
@@ -53,17 +53,17 @@ def remove_chat(bot: Bot, update: Update):
5353
user = update.effective_user
5454
is_chat = sql.is_chat(chat.id)
5555
if not is_chat:
56-
msg.reply_text("AI isn't enabled here in the first place!")
56+
chat.send_message("AI isn't enabled here in the first place!")
5757
return ""
5858
else:
5959
sql.rem_chat(chat.id)
60-
msg.reply_text("AI disabled successfully!")
60+
chat.send_message("AI disabled successfully!")
6161
message = (f"<b>{html.escape(chat.title)}:</b>\n"
6262
f"#AI_DISABLED\n"
6363
f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n")
6464
return message
65-
66-
65+
66+
6767
def check_message(bot: Bot, message):
6868
reply_msg = message.reply_to_message
6969
if message.text.lower() == "saitama":
@@ -73,8 +73,8 @@ def check_message(bot: Bot, message):
7373
return True
7474
else:
7575
return False
76-
77-
76+
77+
7878
@run_async
7979
def chatbot(bot: Bot, update: Update):
8080
global api_client
@@ -101,10 +101,11 @@ def chatbot(bot: Bot, update: Update):
101101
bot.send_chat_action(chat_id, action='typing')
102102
rep = api_client.think_thought(sesh, query)
103103
sleep(0.3)
104-
msg.reply_text(rep, timeout=60)
104+
chat.send_message(rep, timeout=60)
105105
except CFError as e:
106106
bot.send_message(OWNER_ID, f"Chatbot error: {e} occurred in {chat_id}!")
107-
107+
108+
108109
@run_async
109110
def list_chatbot_chats(bot: Bot, update: Update):
110111
chats = sql.get_all_chats()

0 commit comments

Comments
 (0)