mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 00:35:36 +00:00
yinglish 能把中文翻译成淫语的翻译机 (#179)
Co-authored-by: Xtao_dada <xtao@xtaolink.cn>
This commit is contained in:
parent
0cc5f31381
commit
cfac5c26c2
@ -67,6 +67,7 @@
|
|||||||
- `paolu` : 一键跑路(删所有消息并禁言)。
|
- `paolu` : 一键跑路(删所有消息并禁言)。
|
||||||
- `keyword` : 群组关键词自动回复插件。
|
- `keyword` : 群组关键词自动回复插件。
|
||||||
- `msgst` : 每天定时发送消息。
|
- `msgst` : 每天定时发送消息。
|
||||||
|
- `yinglish` : 能把中文翻译成淫语的翻译机.
|
||||||
- profile (资料类)
|
- profile (资料类)
|
||||||
- `autochangename` : 自动更新 last_name 为时间等。
|
- `autochangename` : 自动更新 last_name 为时间等。
|
||||||
- `throwit` : 生成一张 扔头像 图片。
|
- `throwit` : 生成一张 扔头像 图片。
|
||||||
|
10
list.json
10
list.json
@ -759,6 +759,16 @@
|
|||||||
"supported": true,
|
"supported": true,
|
||||||
"des-short": "在贴纸被回复时自动删除贴纸防止被偷取",
|
"des-short": "在贴纸被回复时自动删除贴纸防止被偷取",
|
||||||
"des": "在贴纸被回复时自动删除贴纸防止被偷取。\n网速争霸 不保证成功率"
|
"des": "在贴纸被回复时自动删除贴纸防止被偷取。\n网速争霸 不保证成功率"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "yinglish",
|
||||||
|
"version": "1.00",
|
||||||
|
"section": "chat",
|
||||||
|
"maintainer": "YU",
|
||||||
|
"size": "1.7 kb",
|
||||||
|
"supported": true,
|
||||||
|
"des-short": "能把中文翻译成淫语的翻译机",
|
||||||
|
"des": "能把中文自动翻译成淫语的翻译机\n 需要 pypi 前置 jieba \n 灵感来自于https://github.com/RimoChan/yinglish \n指令:-yinglish"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
74
yinglish.py
Normal file
74
yinglish.py
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import random
|
||||||
|
from asyncio import sleep
|
||||||
|
from sys import executable
|
||||||
|
from pagermaid import log
|
||||||
|
from pagermaid.listener import listener
|
||||||
|
from pagermaid.utils import alias_command, execute
|
||||||
|
|
||||||
|
imported = True
|
||||||
|
try:
|
||||||
|
import jieba
|
||||||
|
import jieba.posseg as pseg
|
||||||
|
jieba.setLogLevel(20)
|
||||||
|
except ImportError:
|
||||||
|
imported = False
|
||||||
|
|
||||||
|
|
||||||
|
def chaos (x, y, chaosrate):
|
||||||
|
if random.random() > chaosrate:
|
||||||
|
return x
|
||||||
|
if x in {'[', ']'}:
|
||||||
|
return ''
|
||||||
|
if x in {','}:
|
||||||
|
return '…'
|
||||||
|
if x in { '!', '!',}:
|
||||||
|
return '‼‼‼'
|
||||||
|
if x in { '。'}:
|
||||||
|
return '❗'
|
||||||
|
if len(x) > 1 and random.random() < 0.1:
|
||||||
|
return f'{x[0]}…{x}'
|
||||||
|
if len(x) > 1 and random.random() < 0.4:
|
||||||
|
return f'{x[0]}♥{x}'
|
||||||
|
if y == 'n' and random.random() < 0.1:
|
||||||
|
x = '⭕' * len(x)
|
||||||
|
return f'…{x}'
|
||||||
|
if x in { '\……n', '\♥n'}:
|
||||||
|
return '\n'
|
||||||
|
if x in { '…………'}:
|
||||||
|
return '……'
|
||||||
|
else:
|
||||||
|
if y == 'n' and random.random() < 0.2:
|
||||||
|
x = '⭕' * len(x)
|
||||||
|
return f'……{x}'
|
||||||
|
|
||||||
|
|
||||||
|
def chs2yin(s, chaosrate =0.8):
|
||||||
|
return ''.join(chaos (x, y, chaosrate) for x, y in pseg.cut(s))
|
||||||
|
|
||||||
|
|
||||||
|
@listener(is_plugin=True, outgoing=True, command=alias_command("yinglish"),
|
||||||
|
description="能把中文和英文翻译成淫语的翻译机!",
|
||||||
|
parameters="<message>|要转换的内容")
|
||||||
|
async def yinglish(context):
|
||||||
|
if not imported:
|
||||||
|
try:
|
||||||
|
await context.edit("支持库 `jieba` 未安装...\n正在尝试自动安装...")
|
||||||
|
await execute(f'{executable} -m pip install jieba')
|
||||||
|
await sleep(10)
|
||||||
|
result = await execute(f'{executable} -m pip show jieba')
|
||||||
|
if len(result) > 0:
|
||||||
|
await context.edit('支持库 `jieba` 安装成功...\n正在尝试自动重启...')
|
||||||
|
await context.client.disconnect()
|
||||||
|
else:
|
||||||
|
await context.edit(f"自动安装失败..请尝试手动安装 `{executable} -m pip install jieba` 随后,请重启 PagerMaid-Modify 。")
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
if context.text and not context.via_bot and not context.forward and not context.parameter:
|
||||||
|
await context.edit(f"你没说话我转换个啥")
|
||||||
|
elif context.text and context.parameter and not context.via_bot and not context.forward:
|
||||||
|
outputtext=chs2yin(context.arguments)
|
||||||
|
await context.edit(f"{outputtext}")
|
||||||
|
await log(f"转换啦!从{context.parameter}变成了{str(outputtext)}!!!")
|
||||||
|
else :
|
||||||
|
await context.edit("error")
|
Loading…
Reference in New Issue
Block a user