2023-12-28 15:50:23 +01:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
|
|
|
|
|
1) Send message to inviter that bot has joined to groupchat.
|
|
|
|
|
|
|
|
|
|
2) If groupchat requires captcha, send the consequent message.
|
|
|
|
|
|
|
|
|
|
3) If groupchat error is received, send that error message to inviter.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
2023-12-28 17:22:32 +01:00
|
|
|
|
import slixfeed.xmpp.bookmark as bookmark
|
2023-12-28 15:50:23 +01:00
|
|
|
|
|
|
|
|
|
async def join_groupchat(self, inviter, muc_jid):
|
|
|
|
|
# token = await initdb(
|
|
|
|
|
# muc_jid,
|
|
|
|
|
# get_settings_value,
|
|
|
|
|
# "token"
|
|
|
|
|
# )
|
|
|
|
|
# if token != "accepted":
|
|
|
|
|
# token = randrange(10000, 99999)
|
|
|
|
|
# await initdb(
|
|
|
|
|
# muc_jid,
|
|
|
|
|
# set_settings_value,
|
|
|
|
|
# ["token", token]
|
|
|
|
|
# )
|
|
|
|
|
# self.send_message(
|
|
|
|
|
# mto=inviter,
|
|
|
|
|
# mbody=(
|
|
|
|
|
# "Send activation token {} to groupchat xmpp:{}?join."
|
|
|
|
|
# ).format(token, muc_jid)
|
|
|
|
|
# )
|
|
|
|
|
print("muc_jid")
|
|
|
|
|
print(muc_jid)
|
|
|
|
|
self.plugin['xep_0045'].join_muc(
|
|
|
|
|
muc_jid,
|
|
|
|
|
self.nick,
|
|
|
|
|
# If a room password is needed, use:
|
|
|
|
|
# password=the_room_password,
|
|
|
|
|
)
|
2023-12-28 17:22:32 +01:00
|
|
|
|
await bookmark.add(self, muc_jid)
|
2023-12-28 15:50:23 +01:00
|
|
|
|
messages = [
|
|
|
|
|
"Greetings!",
|
|
|
|
|
"I'm {}, the news anchor.".format(self.nick),
|
|
|
|
|
"My job is to bring you the latest news "
|
|
|
|
|
"from sources you provide me with.",
|
|
|
|
|
"You may always reach me via "
|
|
|
|
|
"xmpp:{}?message".format(self.boundjid.bare)
|
|
|
|
|
]
|
|
|
|
|
for message in messages:
|
|
|
|
|
self.send_message(
|
|
|
|
|
mto=muc_jid,
|
|
|
|
|
mbody=message,
|
|
|
|
|
mtype="groupchat"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def close_groupchat(self, muc_jid):
|
|
|
|
|
messages = [
|
|
|
|
|
"Whenever you need an RSS service again, "
|
|
|
|
|
"please don’t hesitate to contact me.",
|
|
|
|
|
"My personal contact is xmpp:{}?message".format(self.boundjid.bare),
|
|
|
|
|
"Farewell, and take care."
|
|
|
|
|
]
|
|
|
|
|
for message in messages:
|
|
|
|
|
self.send_message(
|
|
|
|
|
mto=muc_jid,
|
|
|
|
|
mbody=message,
|
|
|
|
|
mtype="groupchat"
|
|
|
|
|
)
|
2023-12-28 17:22:32 +01:00
|
|
|
|
await bookmark.remove(self, muc_jid)
|
2023-12-28 15:50:23 +01:00
|
|
|
|
self.plugin['xep_0045'].leave_muc(
|
|
|
|
|
muc_jid,
|
|
|
|
|
self.nick,
|
|
|
|
|
"Goodbye!",
|
|
|
|
|
self.boundjid.bare
|
|
|
|
|
)
|
|
|
|
|
|