Compare commits
3 Commits
0cf4b18192
...
e1177d388d
Author | SHA1 | Date |
---|---|---|
Alex Kotov | e1177d388d | |
Alex Kotov | f78baf0f68 | |
Alex Kotov | 87308db512 |
|
@ -1 +1,3 @@
|
|||
__pycache__/
|
||||
|
||||
/.env
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
FROM ubuntu:22.10
|
||||
RUN mkdir /app
|
||||
RUN mkdir -p /app/mirrortea/
|
||||
WORKDIR /app
|
||||
RUN apt-get update --yes
|
||||
RUN apt-get install --yes python3 python3-pip
|
||||
COPY requirements.txt /app
|
||||
COPY requirements.txt /app/
|
||||
RUN pip3 install -r requirements.txt
|
||||
COPY mirrortea /app
|
||||
ENTRYPOINT ["/app/mirrortea"]
|
||||
COPY mirrortea/* /app/mirrortea/
|
||||
ENTRYPOINT ["/usr/bin/python3", "/app/mirrortea"]
|
||||
|
|
|
@ -4,3 +4,5 @@ services:
|
|||
app:
|
||||
build: .
|
||||
env_file: '.env'
|
||||
volumes:
|
||||
- './mirrortea:/app/mirrortea/'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import sys
|
||||
|
@ -16,15 +14,18 @@ async def main():
|
|||
try:
|
||||
matrix_client = \
|
||||
matrix.AsyncClient(MATRIX_HOMESERVER_URL, MATRIX_FULL_USER_ID)
|
||||
|
||||
matrix_client.add_event_callback(matrix_on_message,
|
||||
matrix.RoomMessage)
|
||||
|
||||
await matrix_client.login(MATRIX_PASSWORD)
|
||||
|
||||
telegram_client = telegram.Bot(token=TELEGRAM_BOT_TOKEN)
|
||||
telegram_bot = telegram.Bot(token=TELEGRAM_BOT_TOKEN)
|
||||
telegram_dispatcher = telegram.Dispatcher(bot=telegram_bot)
|
||||
telegram_dispatcher.register_message_handler(telegram_on_message)
|
||||
|
||||
await asyncio.gather(matrix_loop(matrix_client), telegram_loop())
|
||||
await asyncio.gather(
|
||||
matrix_loop(matrix_client),
|
||||
telegram_loop(),
|
||||
)
|
||||
finally:
|
||||
if matrix_client:
|
||||
await matrix_client.close()
|
||||
|
@ -38,5 +39,8 @@ async def telegram_loop():
|
|||
async def matrix_on_message(room, event):
|
||||
print(room, event, file=sys.stderr)
|
||||
|
||||
async def telegram_on_message(msg):
|
||||
print(msg, file=sys.stderr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
Loading…
Reference in New Issue