parent
6af66e2f4a
commit
f74f3a6df7
|
@ -4,10 +4,9 @@ WORKDIR /bot
|
||||||
|
|
||||||
COPY Pipfile .
|
COPY Pipfile .
|
||||||
RUN pip install pipenv && \
|
RUN pip install pipenv && \
|
||||||
pipenv install --pre && \
|
pip install pipfile-requirements
|
||||||
pipenv install --deploy --system && \
|
RUN pipfile2req Pipfile > requirements.txt
|
||||||
rm -r /root/.cache/* && \
|
RUN pip install -r requirements.txt
|
||||||
rm -r /root/.local/*
|
|
||||||
|
|
||||||
COPY bot.py *.json *.pickle /bot/
|
COPY bot.py *.json *.pickle /bot/
|
||||||
COPY config config
|
COPY config config
|
||||||
|
|
2
Pipfile
2
Pipfile
|
@ -15,7 +15,7 @@ requests = "*"
|
||||||
igramscraper = "*"
|
igramscraper = "*"
|
||||||
twitterscraper = "*"
|
twitterscraper = "*"
|
||||||
httpx = "*"
|
httpx = "*"
|
||||||
pyyaml = "==5.3"
|
PyYAML = "==5.3"
|
||||||
wolframalpha = "*"
|
wolframalpha = "*"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
|
@ -354,6 +354,11 @@ bot ownership)
|
||||||
* !flog rmlive - disable live field log for this room
|
* !flog rmlive - disable live field log for this room
|
||||||
* !flog timezone 3 - set timezone (relative to UTC, see API docs)
|
* !flog timezone 3 - set timezone (relative to UTC, see API docs)
|
||||||
|
|
||||||
|
### Jitsi
|
||||||
|
|
||||||
|
If enabled, Jitsi calls created with Matrix clients will be sent as text messages
|
||||||
|
to rooms, allowing non-matrix users to join them.
|
||||||
|
|
||||||
## Bot setup
|
## Bot setup
|
||||||
|
|
||||||
* Create a Matrix user
|
* Create a Matrix user
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
from nio import RoomMessageUnknown, UnknownEvent
|
||||||
|
|
||||||
|
from modules.common.module import BotModule
|
||||||
|
|
||||||
|
|
||||||
|
class MatrixModule(BotModule):
|
||||||
|
bot = None
|
||||||
|
|
||||||
|
def matrix_start(self, bot):
|
||||||
|
super().matrix_start(bot)
|
||||||
|
self.bot = bot
|
||||||
|
bot.client.add_event_callback(self.unknownevent_cb, (UnknownEvent,))
|
||||||
|
|
||||||
|
def matrix_stop(self, bot):
|
||||||
|
super().matrix_stop(bot)
|
||||||
|
bot.remove_callback(self.unknownevent_cb)
|
||||||
|
|
||||||
|
async def unknownevent_cb(self, room, event):
|
||||||
|
if event.type == 'im.vector.modular.widgets' and event.source['content']['type'] == 'jitsi':
|
||||||
|
domain = event.source['content']['data']['domain']
|
||||||
|
conferenceId = event.source['content']['data']['conferenceId']
|
||||||
|
isAudioOnly = event.source['content']['data']['isAudioOnly']
|
||||||
|
sender = event.source['sender']
|
||||||
|
sender_response = await self.bot.client.get_displayname(event.sender)
|
||||||
|
sender = sender_response.displayname
|
||||||
|
# This is just a guess - is this the proper way to generate URL? Probably not.
|
||||||
|
jitsiUrl = f'https://{domain}/{conferenceId}'
|
||||||
|
|
||||||
|
calltype = 'video call'
|
||||||
|
if isAudioOnly:
|
||||||
|
calltype = 'audio call'
|
||||||
|
|
||||||
|
plainMessage = f'{sender} started a {calltype}: {jitsiUrl}'
|
||||||
|
htmlMessage = f'{sender} started a <a href="{jitsiUrl}">{calltype}</a>'
|
||||||
|
await self.bot.send_html(room, htmlMessage, plainMessage)
|
||||||
|
|
||||||
|
async def matrix_message(self, bot, room, event):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def help(self):
|
||||||
|
return 'Sends text links when user starts a Jitsi video or audio call in room'
|
|
@ -3,8 +3,6 @@ from nio import RoomMessageUnknown
|
||||||
|
|
||||||
from modules.common.module import BotModule
|
from modules.common.module import BotModule
|
||||||
|
|
||||||
from modules.common.module import BotModule
|
|
||||||
|
|
||||||
|
|
||||||
class MatrixModule(BotModule):
|
class MatrixModule(BotModule):
|
||||||
bot = None
|
bot = None
|
||||||
|
|
Loading…
Reference in New Issue