Ejemplo n.º 1
0
async def random_echo(bot, event):
    echo_folder = R.get('record/echo/').path
    files = os.listdir(echo_folder)
    filename = random.choice(files)
    file = R.get('record/echo/', filename)
    rec = MessageSegment.record(f'file:///{os.path.abspath(file.path)}')
    await bot.send(event, rec)
Ejemplo n.º 2
0
async def hso(bot, event):
    if random.random() <= 0.2:
        voice = R.get('record/echo/', 'hso.mp3')
    elif random.random() > 0.2 and random.random() <= 0.5:
        voice = R.get('record/echo/', 'cheche.mp3')
    elif random.random() > 0.5 and random.random() <= 0.6:
        voice = R.get('record/echo/', 'echohso.mp3')
    else:
        voice = R.get('record/echo/', 'hso.mp3')
    rec = MessageSegment.record(f'file:///{os.path.abspath(voice.path)}')
    await bot.send(event, rec)
Ejemplo n.º 3
0
async def woaini(bot, event):
    if random.random() <= 0.3:
        voice = R.get('record/echo/', 'jiehun.mp3')
    elif random.random() > 0.3 and random.random() <= 0.6:
        voice = R.get('record/echo/', 'aini.mp3')
    elif random.random() > 0.6 and random.random() <= 0.8:
        voice = R.get('record/echo/', 'woaini.m4a')
    else:
        voice = R.get('record/echo/', 'jiehun2.mp3')
    rec = MessageSegment.record(f'file:///{os.path.abspath(voice.path)}')
    await bot.send(event, rec)
Ejemplo n.º 4
0
async def sleep(bot, event):
    if random.random() <= 0.3:
        voice = R.get('record/echo/', '晚安.mp3')
    elif random.random() > 0.3 and random.random() <= 0.6:
        voice = R.get('record/echo/', '不想睡觉.mp3')
    elif random.random() > 0.6 and random.random() <= 0.8:
        voice = R.get('record/echo/', '不行不行.mp3')
    else:
        voice = R.get('record/echo/', '不想睡觉-n.mp3')
    rec = MessageSegment.record(f'file:///{os.path.abspath(voice.path)}')
    await bot.send(event, rec)
Ejemplo n.º 5
0
async def xcw_jiaochuan(bot, ev) -> MessageSegment:
    roll = random.random()
    if roll <= 0.05:
        filename = '喘息声.mp3'
        file = R.get('img/xcw/record', filename)
        try:
            rec = MessageSegment.record(
                f'file:///{os.path.abspath(file.path)}')
            await bot.send(ev, rec)
        except CQHttpError:
            sv.logger.error("发送失败")
    elif 0.05 < roll <= 0.15:
        file = get_xcw_biantai()
        try:
            rec = MessageSegment.record(
                f'file:///{os.path.abspath(file.path)}')
            await bot.send(ev, rec)
        except CQHttpError:
            sv.logger.error("发送失败")
    elif 0.15 < roll <= 0.4:
        filename = '叹气声.mp3'
        file = R.get('img/xcw/record', filename)
        try:
            rec = MessageSegment.record(
                f'file:///{os.path.abspath(file.path)}')
            await bot.send(ev, rec)
        except CQHttpError:
            sv.logger.error("发送失败")
    elif 0.4 < roll <= 0.75:
        filename = '叹气声2.mp3'
        file = R.get('img/xcw/record', filename)
        try:
            rec = MessageSegment.record(
                f'file:///{os.path.abspath(file.path)}')
            await bot.send(ev, rec)
        except CQHttpError:
            sv.logger.error("发送失败")
    elif 0.75 < roll <= 0.95:
        filename = '叹气声2.mp3'
        file = R.get('img/xcw/record', filename)
        try:
            rec = MessageSegment.record(
                f'file:///{os.path.abspath(file.path)}')
            await bot.send(ev, rec)
        except CQHttpError:
            sv.logger.error("发送失败")
    else:
        await bot.send(ev, '我懂了你是变态吧~', at_sender=True)
Ejemplo n.º 6
0
async def record_send(bot, ev: CQEvent):

    name = ev.message.extract_plain_text().strip()
    if not name:
        await bot.send(ev, '请发送"语音"+角色名,如"语音ue"')
        return
    cid = chara.name2id(name)
    if cid == chara.UNKNOWN:
        msg = f'兰德索尔似乎没有叫"{name}"的人...'
        await bot.send(ev, msg)
        return

    dir_path = R.get('record', str(cid)).path
    if not os.path.exists(dir_path):
        msg = f'未找到"{name}"的语音数据'
        await bot.send(ev, msg)
        return

    file_list = os.listdir(dir_path)
    file_path = None
    while not file_path or not os.path.isfile(file_path):
        filename = random.choice(file_list)
        file_path = os.path.join(dir_path, filename)
    if not file_path:
        msg = f'未找到"{name}"的语音数据'
        await bot.send(ev, msg)
        return
    rec = MessageSegment.record(f'file:///{os.path.abspath(file_path)}')
    await bot.send(ev, rec)
Ejemplo n.º 7
0
async def shangke(bot, ev):
    filename = 'shangke.jpg'
    file = R.get('img/xcw/image', filename)
    try:
        rec = MessageSegment.image(f'file:///{os.path.abspath(file.path)}')
        await bot.send(ev, rec)
    except CQHttpError:
        sv.logger.error("发送失败")
Ejemplo n.º 8
0
async def shigyi(bot, ev):
    if random.random() < 0.5:
        filename = '斯国一斯国一.mp3'
        file = R.get('img/xcw/record', filename)
        try:
            rec = MessageSegment.image(f'file:///{os.path.abspath(file.path)}')
            await bot.send(ev, rec)
        except CQHttpError:
            sv.logger.error("发送失败")
Ejemplo n.º 9
0
def load_index():
    with open(R.get('img/priconne/comic/index.json').path,
              encoding='utf8') as f:
        return json.load(f)
Ejemplo n.º 10
0
def get_token():
    with open(R.get('img/ghs/token.json').path, 'r') as f:
        return json.load(f)
Ejemplo n.º 11
0
def write_refresh_token(token):
    with open(R.get('img/ghs/token.json').path, 'w') as f:
        json.dump(token, fp=f)
Ejemplo n.º 12
0
async def down_video(bot, event):
    url = event.message.extract_plain_text().strip()
    if not url:
        return
    match = re.match(r'https?:/{2}\w.+$', url)
    if not match:
        await bot.send(event, '参数不合法')
        return

    timespan = int(time.time())
    filename = f'{timespan}'
    foloder = R.get('temp/').path
    file = R.get('temp/', f'{filename}.mp4')
    fileabs = os.path.abspath(file.path)
    cover = R.get('temp/', f'{filename}.mp4.jpg')
    # coverabs = os.path.abspath(cover.path)

    if not os.path.exists(foloder):
        os.mkdir(foloder)
    try:
        info_thread = Thread.MyThread(get_video_info, args=(url, ))
        info_thread.start()
        info_thread.join()
        info = info_thread.get_result()
        match = re.search(r'MPEG-4 video(.*)\s*Size:(.*)MiB', info)
        if not match:
            await bot.send(event, '参数不正确')
            return
        info_type = match.group(1).strip()
        if info_type != '(video/mp4)':
            await bot.send(event, '未找到视频信息')
            return
        info_size = match.group(2).strip()
        if not util.is_number(info_size):
            await bot.send(event, '无法获取视频大小')
            return
        size = float(info_size)
        if size >= 6.0:
            await bot.send(event, '视频体积过大')
            return

        await bot.send(event, '正在发送...')

        down_thread = Thread.MyThread(download_video,
                                      args=(
                                          url,
                                          foloder,
                                          filename,
                                      ))
        down_thread.start()
        down_thread.join()
    except Exception as e:
        sv.logger.error(e)
        await bot.send(event, '获取视频失败了')
        os.remove(file.path)
        os.remove(cover.path)
        return

    # video = MessageSegment(type_='video', data={'file': fileabs, 'cover': coverabs, 'c': 2})
    video = f'[CQ:video,file=file:///{fileabs}]'
    try:
        await bot.send(event, video)
    except:
        await bot.send(event, '发送失败了')
    os.remove(file.path)
    os.remove(cover.path)
Ejemplo n.º 13
0
def get_xcw_kkp():
    files = os.listdir(xcw_folder_kkp)
    filename = random.choice(files)
    rec = R.get('img/xcw/record/kkp', filename)
    return rec
Ejemplo n.º 14
0
def get_xcw_mawo():  #get
    files = os.listdir(xcw_folder_mawo)  #folder
    filename = random.choice(files)
    rec = R.get('img/xcw/record/mawo/', filename)  #folder
    return rec
Ejemplo n.º 15
0
def get_xcw_pa():
    files = os.listdir(xcw_folder_pa)
    filename = random.choice(files)
    rec = R.get('img/xcw/image/pa', filename)
    return rec
Ejemplo n.º 16
0
def get_lbw():
    files = os.listdir(lbw_folder)
    filename = random.choice(files)
    rec = R.get('record/55k/', filename)
    return rec
Ejemplo n.º 17
0
import os
import random

from nonebot.exceptions import CQHttpError
from nonebot import MessageSegment

from hoshino import R, Service, priv

sv = Service('mawo', enable_on_default=True, visible=False)
xcw_folder = R.get('record/mawo/').path
lbw_folder = R.get('record/55k/').path
ai_folder = R.get('record/ai/').path
dsm_folder = R.get('record/dsm/').path
shabi_folder = R.get('record/shabi/').path
chongju_folder = R.get('record/chongju/').path


def get_xcw():
    files = os.listdir(xcw_folder)
    filename = random.choice(files)
    rec = R.get('record/mawo/', filename)
    return rec


def get_lbw():
    files = os.listdir(lbw_folder)
    filename = random.choice(files)
    rec = R.get('record/55k/', filename)
    return rec

Ejemplo n.º 18
0
import pytz
import random
import os
from datetime import datetime
import hoshino
from hoshino import Service, R
from nonebot import MessageSegment

sv = Service('hourcall', enable_on_default=False, help_='时报')
tz = pytz.timezone('Asia/Shanghai')
record_folder = R.get('record/hourcall/').path
record_pre = ('181a-', '185-', '283a-')


def get_hour_call():
    """挑出一组时报,每日更换,一日之内保持相同"""
    cfg = hoshino.config.hourcall
    now = datetime.now(tz)
    hc_groups = cfg.HOUR_CALLS_ON
    g = hc_groups[now.day % len(hc_groups)]
    return cfg.HOUR_CALLS[g]


@sv.scheduled_job('cron', hour='*')
async def hour_call():
    now = datetime.now(tz)
    if 2 <= now.hour <= 4:
        return  # 宵禁 免打扰
    msg = get_hour_call()[now.hour]
    chosen_file = random.choice(record_pre) + str(now.hour).zfill(2) + '00.mp3'
    record_path = os.path.join(record_folder, chosen_file)
Ejemplo n.º 19
0
def get_xcw_biantai():
    files = os.listdir(xcw_folder_biantai)
    filename = random.choice(files)
    rec = R.get('img/xcw/record/biantai', filename)
    return rec
Ejemplo n.º 20
0
import os
import random


from nonebot.exceptions import CQHttpError
from nonebot import MessageSegment


from hoshino import R, Service, priv


sv = Service('xcwhentai', enable_on_default=True, visible=False)
xcw_folder = R.get('record/mawo/').path


def get_xcw():
    files = os.listdir(xcw_folder)
    filename = random.choice(files)
    rec = R.get('record/mawo/', filename)
    return rec


@sv.on_fullmatch(('骂我','变态','hentai'))
async def xcw(bot, ev) -> MessageSegment:
    # conditions all ok, send a xcw.
    file = get_xcw()
    try:
        rec = MessageSegment.record(f'file:///{os.path.abspath(file.path)}')
        await bot.send(ev, rec)
    except CQHttpError:
        sv.logger.error("发送失败")
Ejemplo n.º 21
0
    use_priv=priv.NORMAL,  #使用权限   
    manage_priv=priv.ADMIN,  #管理权限
    visible=True,  #是否可见
    enable_on_default=True,  #是否默认启用
    bundle='通用',  #属于哪一类
    help_=sv_help  #帮助文本
)


@sv.on_fullmatch(["帮助xcw"])
async def bangzhu(bot, ev):
    await bot.send(ev, sv_help, at_sender=True)


'''-----随机发送文件夹内容①----------'''
xcw_folder_mawo = R.get('img/xcw/record/mawo/').path
xcw_folder_pa = R.get('img/xcw/image/pa/').path
xcw_folder_huhuhu = R.get('img/xcw/image/huhuhu/').path
xcw_folder_kkp = R.get('img/xcw/record/kkp/').path
xcw_folder_biantai = R.get('img/xcw/record/biantai/').path
'''-----随机发送文件夹内容②----------'''


def get_xcw_mawo():  #get
    files = os.listdir(xcw_folder_mawo)  #folder
    filename = random.choice(files)
    rec = R.get('img/xcw/record/mawo/', filename)  #folder
    return rec


def get_xcw_pa():
Ejemplo n.º 22
0
def get_xcw():
    files = os.listdir(xcw_folder)
    filename = random.choice(files)
    rec = R.get('record/mawo/', filename)
    return rec
Ejemplo n.º 23
0
def get_shabi():
    files = os.listdir(shabi_folder)
    filename = random.choice(files)
    rec = R.get('record/shabi/', filename)
    return rec
Ejemplo n.º 24
0
async def shengrige(bot, event):
    voice = R.get('record/echo/', 'shengri.mp3')
    rec = MessageSegment.record(f'file:///{os.path.abspath(voice.path)}')
    await bot.send(event, rec)
Ejemplo n.º 25
0
def get_chongju():
    files = os.listdir(chongju_folder)
    filename = random.choice(files)
    rec = R.get('record/chongju/', filename)
    return rec
Ejemplo n.º 26
0
def get_ai():
    files = os.listdir(ai_folder)
    filename = random.choice(files)
    rec = R.get('record/ai/', filename)
    return rec
Ejemplo n.º 27
0
def get_xcw_huhuhu():
    files = os.listdir(xcw_folder_huhuhu)
    filename = random.choice(files)
    rec = R.get('img/xcw/image/huhuhu', filename)
    return rec
Ejemplo n.º 28
0
def get_dsm():
    files = os.listdir(dsm_folder)
    filename = random.choice(files)
    rec = R.get('record/dsm/', filename)
    return rec
Ejemplo n.º 29
0
import os
import random

from nonebot.exceptions import CQHttpError
from nonebot import MessageSegment

from hoshino import R, Service, priv

sv = Service('xcw', enable_on_default=True, visible=False)
xcw_folder = R.get('record/xcw/').path


def get_xcw():
    files = os.listdir(xcw_folder)
    filename = random.choice(files)
    rec = R.get('record/xcw/', filename)
    return rec


@sv.on_fullmatch('骂我', only_to_me=True)
async def xcw(bot, ev) -> MessageSegment:
    # conditions all ok, send a xcw.
    file = get_xcw()
    try:
        rec = MessageSegment.record(f'file:///{os.path.abspath(file.path)}')
        await bot.send(ev, rec)
    except CQHttpError:
        sv.logger.error("发送失败")