add more customized plugins
parent
0984d2f8e0
commit
2a05df47c1
|
@ -0,0 +1,19 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from telethon import events
|
||||
import random, re
|
||||
|
||||
@borg.on(events.NewMessage(pattern=r".decide", outgoing=True))
|
||||
async def _(event):
|
||||
if event.fwd_from:
|
||||
return
|
||||
r = random.randint(1, 100)
|
||||
if r % 3 == 1:
|
||||
await event.edit("Yes")
|
||||
elif r % 3 == 2:
|
||||
await event.edit("No")
|
||||
else:
|
||||
await event.edit("¯\_(ツ)_/¯")
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from telethon import events
|
||||
import requests
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
current_date_time = "./../DOWNLOADS/"
|
||||
|
||||
|
||||
@borg.on(events.NewMessage(pattern=r".tts (.*)", outgoing=True))
|
||||
async def _(event):
|
||||
if event.fwd_from:
|
||||
return
|
||||
input_str = event.pattern_match.group(1)
|
||||
start = datetime.now()
|
||||
tts_url = "https://tts.baidu.com/text2audio?lan={}&ie=UTF-8&text={}"
|
||||
lan, text = input_str.split("|")
|
||||
input_url = tts_url.format(lan.strip(), text.strip())
|
||||
response = requests.get(input_url, stream=True)
|
||||
required_file_name = current_date_time + "voice.ogg"
|
||||
with open(required_file_name, "wb") as fd:
|
||||
for chunk in response.iter_content(chunk_size=128):
|
||||
fd.write(chunk)
|
||||
await borg.send_file(
|
||||
event.chat_id,
|
||||
required_file_name,
|
||||
reply_to=event.message.id,
|
||||
allow_cache=False,
|
||||
voice_note=True
|
||||
)
|
||||
os.remove(required_file_name)
|
||||
end = datetime.now()
|
||||
ms = (end - start).seconds
|
||||
output_str = "Processed {} ({}) in {} seconds!"
|
||||
await event.edit(output_str.format(text, lan, ms))
|
||||
|
|
@ -58,7 +58,7 @@ async def _(event):
|
|||
input_str,
|
||||
force_document=True,
|
||||
allow_cache=False,
|
||||
reply_to=event.message.reply_to_msg_id
|
||||
reply_to=event.message.id
|
||||
)
|
||||
end = datetime.now()
|
||||
ms = (end - start).seconds
|
||||
|
@ -79,9 +79,10 @@ async def _(event):
|
|||
await borg.send_file(
|
||||
event.chat_id,
|
||||
input_str,
|
||||
caption=input_str,
|
||||
force_document=False,
|
||||
allow_cache=False,
|
||||
reply_to=event.message.reply_to_msg_id,
|
||||
reply_to=event.message.id,
|
||||
attributes=[
|
||||
DocumentAttributeVideo(
|
||||
duration=metadata.get("duration").seconds,
|
||||
|
|
Reference in New Issue