announce on telegram
This commit is contained in:
parent
06f10fd479
commit
a569dde23b
11 changed files with 62 additions and 7 deletions
26
app/telegrambot/rpc.py
Normal file
26
app/telegrambot/rpc.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import asyncio
|
||||
|
||||
import telegram
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def send(msg, to=None, channel=None, preview_url=None, preview_title=None, preview_description=None, preview_image=None):
|
||||
bot = telegram.Bot(token=settings.TELEGRAM_TOKEN)
|
||||
if preview_image:
|
||||
asyncio.run(bot.send_photo(
|
||||
chat_id=channel,
|
||||
caption=msg,
|
||||
photo=preview_image,
|
||||
parse_mode='html'
|
||||
))
|
||||
else:
|
||||
asyncio.run(bot.send_message(
|
||||
chat_id=channel,
|
||||
text=msg,
|
||||
parse_mode='html'
|
||||
))
|
||||
|
||||
|
||||
def send_reaction(target_address, target_ts, emoji, to=None, group=None, remove=False):
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue