from hoshino import Service
from hoshino.util import FreqLimiter

sv_help = '''
[查询排名] 接排名 查询最新该排名公会
[查询公会] 接公会名称 查询最新该公会
[查询会长] 接会长名称 查询最新该会长公会
[查询分数] 接分数 查询最新该分数公会
[查询档线] 查询最新各档线分数
'''.strip()
sv = Service('clanrank', enable_on_default=True, bundle='pcr排名', help_=sv_help)

from . import query

lmt = FreqLimiter(10)


@sv.on_prefix(('查询公会', '公会查询'))
async def name_query(bot, ev):
    uid = ev.user_id

    if not lmt.check(uid):
        await bot.finish(ev, '您查询得过于频繁,请稍等片刻', at_sender=True)

    # 处理输入数据
    name = ev.message.extract_plain_text()
    if len(name) == 0:
        await bot.finish(ev, "请发送'查询公会+行会名称'进行查询,无需+号", at_sender=True)

    lmt.start_cd(uid)
Exemple #2
0
import aiohttp
from hoshino import R, Service, util
"""
反骑空士
"""
sv = Service('反骑空士', help_='识破骑空士的阴谋\n')

qksimg = R.img('antiqks.jpg').cqcode

@sv.on_keyword("granbluefantasy.jp")
async def qks_keyword(bot, ev):
    msg = f'骑空士爪巴\n{qksimg}'
    await bot.send(ev, msg, at_sender=True)
    await util.silence(ev, 60)

# 有潜在的安全问题
# @sv.on_rex(r'[a-zA-Z0-9\.]{4,12}\/[a-zA-Z0-9]+')
async def qks_rex(bot, ev):
    match = ev.match
    msg = f'骑空士爪巴远点\n{qksimg}'
    res = 'http://'+match.group(0)
    async with aiohttp.TCPConnector(verify_ssl=False) as connector:
        async with aiohttp.request(
            'GET',
            url=res,
            allow_redirects=False,
            connector=connector,
        ) as resp:
            h = resp.headers
            s = resp.status
    if s == 301 or s == 302:
Exemple #3
0
from .._util import extract_url_from_event
from .data_source import detect_face, concat, gen_head
from .opencv import add
from .config import *

sv_help = '''
- [接头1 XX] XX为一张图片,三次元限定,否则生草
- [接头2 XX] XX为一张图片,二次元限定,否则生草
- [接头  XX] 默认二次元接头
'''.strip()

sv = Service(
    name = '接头霸王',  #功能名
    use_priv = priv.NORMAL, #使用权限   
    manage_priv = priv.ADMIN, #管理权限
    visible = True, #是否可见
    enable_on_default = True, #是否默认启用
    bundle = '娱乐', #属于哪一类
    help_ = sv_help #帮助文本
    )

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

_nlt = DailyNumberLimiter(5)
_flt = FreqLimiter(5)

@sv.on_prefix(('接头霸王', '接头'))
async def concat_head(bot: HoshinoBot, ev: CQEvent):
import re
from io import BytesIO
from os import path

from PIL import Image
from nonebot.message import MessageSegment

from hoshino import Service, aiorequests
from hoshino.typing import HoshinoBot, CQEvent
from .data_source import generate_gif

sv = Service('Rua')
data_dir = path.join(path.dirname(__file__), 'data')


@sv.on_message()
async def creep(bot: HoshinoBot, ev: CQEvent):
    match = re.match(r'(?:(?:rua)|(?:Rua)|搓)\[CQ:at,qq=(\d+?)\]',
                     ev.raw_message)
    if not match:
        match = re.match(r'\[CQ:at,qq=(.+?)\] (?:(?:rua)|(?:Rua)|搓)',
                         ev.raw_message)
    if not match:
        return
    creep_id = match.group(1)

    url = f'http://q1.qlogo.cn/g?b=qq&nk={creep_id}&s=160'
    resp = await aiorequests.get(url)
    resp_cont = await resp.content
    avatar = Image.open(BytesIO(resp_cont))
    output = generate_gif(data_dir, avatar)
Exemple #5
0
import os
import nonebot
from quart import request,session,redirect,Blueprint,url_for,render_template,jsonify,session
from nonebot.exceptions import CQHttpError
from pathlib import Path
from hoshino import R, Service, priv, config
from hoshino.util import DailyNumberLimiter

public_address = config.IP#修改为服务器公网ip
meManagePwd = 'xcw'#删除文件密码
loginUserName = '******'#登录账户
loginPassword = '******'#登录密码
bot_name = 'xcw'#机器人名字
group_name = '镜华的表情包'#公会名

sv = Service('meme_web', manage_priv=priv.SUPERUSER, enable_on_default=True, visible=False)
work_env = Path(os.path.dirname(__file__))
meme_folder = work_env.joinpath('meme')
static_folder = work_env.joinpath('static')
me = Blueprint('me',__name__,template_folder='templates',static_folder=static_folder)
bot = nonebot.get_bot()
app = bot.server_app
sv.logger.info(meme_folder)


@sv.on_rex('^查看.{0,}表情$')
async def meme_query(bot, ev):
    uid = ev.user_id
    #文件查找
    arv = ev.message.extract_plain_text()
    l = len(arv)
Exemple #6
0
from hoshino import Service, priv
from hoshino.typing import CQEvent

sv = Service('_help_', manage_priv=priv.SUPERUSER, visible=False)

TOP_MANUAL = '''
新增功能:
[生成表情+关键字+图片] 生成表情
[#抽签|人品|运势|抽凯露签] 随机角色/指定凯露预测今日运势
=====================
- 七七群Bot使用说明 -
=====================
发送方括号[]内的关键词即可触发
※功能采取模块化管理,群管理可控制开关

[#来发十连] 转蛋模拟
[会战面板] http://140.143.169.143/yobot/user/ 
[会战帮助] http://140.143.169.143/yobot/help/ 
[会战手册] http://140.143.169.143/yobot/manual/ 
[lssv] 查看功能模块的开关状态(群管理限定)

发送以下关键词查看更多:
[帮助pcr查询]
[帮助pcr娱乐]
[帮助pcr订阅]
[帮助通用]
========
※除这里中写明外 另有其他隐藏功能:)
'''.strip()

import asyncio
import os
import random

from hoshino import Service, util
from hoshino.typing import MessageSegment, CQEvent
from . import game_util, GameMaster


sv = Service('pcr-neurasthenia', bundle='pcr娱乐', help_='''
[神经衰弱] 开启一局公主连结主题的神经衰弱小游戏
[神经衰弱排行] 查看神经衰弱小游戏群排行
'''.strip())


# 神经衰弱(Neurasthenia)小游戏相关参数
ROW_NUM = 4
COL_NUM = 4
SHOW_TIME = 6
ANSWER_TIME = 15
TOTAL_PIC_NUM = ROW_NUM * COL_NUM
DB_PATH = os.path.expanduser("~/.hoshino/pcr_neurasthenia.db")
assert TOTAL_PIC_NUM % 2 == 0

gm = GameMaster(DB_PATH)


@sv.on_fullmatch(("神经衰弱排行", "神经衰弱排行榜", "神经衰弱群排行"))
async def neurasthenia_group_ranking(bot, ev: CQEvent):
    ranking = gm.db.get_ranking(ev.group_id)
    msg = ["【神经衰弱小游戏排行榜】"]
Exemple #8
0
URL = 'https://static.biligame.com/pcr/gw/calendar.js'
header = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'

data = {
    'calendar_days': 7,  # 日程表返回包括今天在内多长时间的日程,默认是7天
    'Refresh_date': '',  # 上次爬取日程表的日期
    'schedule_data': ''  # 从官方日历爬取下来的数据
}

# day_key里保存的是每天的信息分类,"qdhd"是多倍掉落庆典,"tdz"是公会战,
# "tbhd"是公会之家家具上架,"jqhd"是活动地图,"jssr"是角色生日
# 你可以自定义这个列表,删掉不想看到的活动
day_key = ["qdhd", "tdz", "tbhd", "jqhd", "jssr"]


sv = Service('日程表')

@sv.on_fullmatch(('国服日程表','日程表'))
async def Schedule(bot, ev):
    # 调用的时候比对上次爬取日程表时间,不是今天就重新爬取日程表,是今天就直接返回

    if data['Refresh_date'] != str(datetime.date.today()):

        status = refresh_schedule()
        if not status[0]:
            await bot.send(ev, f'刷新日程表失败,错误代码{status[1]}')
            return
        data['Refresh_date'] = str(datetime.date.today())  # 爬取时间改为今天
        await bot.send(ev, return_schedule())
    else:
        await bot.send(ev, return_schedule())
import asyncio
import re
import threading

import nonebot
from nonebot import NLPSession, on_natural_language, NLPResult, on_command, IntentCommand
from nonebot.command import Command, CommandSession
from .wife_config import *
from hoshino import Service

wife_lists = user_list()

sv = Service('laopo', enable_on_default=False)

MANUAL = '''
指令表:
1.老婆
2.老婆的个人信息
3.老婆骂我
4.结婚
5.老婆!/爱我/爱你
6.情话
7.分手
8.我的渣男值
'''.strip()


@sv.on_command('老婆帮助', only_to_me=False)
async def send_laopohelp(session):
    await session.send(MANUAL)
Exemple #10
0
import os
import sqlite3
from datetime import datetime, timedelta

from nonebot import get_bot

import hoshino
from hoshino import Service

sv = Service('ontree_scheduler', enable_on_default=True, help_='挂树提醒')


@sv.on_command('挂树')
async def climb_tree(session):
    #获取上树成员以及其所在群信息
    ctx = session.ctx
    user_id = ctx['user_id']
    group_id = ctx['group_id']
    #连接挂树记录数据库
    con = sqlite3.connect(os.getcwd() +
                          "/hoshino/modules/ontree_scheduler/tree.db")
    cur = con.cursor()
    #查询当前状态是否已经上树,如果在挂树则提示,未挂树则上树
    query = cur.execute(
        f"SELECT COUNT(*) FROM tree WHERE qqid={user_id} AND gid={group_id}")
    for row in query:
        is_ontree = row[0]
    if (is_ontree == 1):
        msg = f'>>>挂树计时提醒[!]\n[CQ:at,qq={user_id}]已经挂树\n请勿重复上树'
    else:
        climb_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
Exemple #11
0
def 购买记录read_json():
    global 购买记录
    try:
        if os.path.exists(购买记录_path):
            with open(购买记录_path, 'r', encoding='utf-8') as f:
                购买记录 = json.load(f)
        else:
            购买记录write_json()
    except:
        pass


购买记录read_json()


sv = Service('群组')

#
# @sv.on_message('group')
# async def handle_group_message(bot, event: aiocqhttp.Event):
#     print(event)
#     if event.raw_message == '测试测试':
#         await bot.send_group_msg(self_id=event.self_id, group_id=messageGroup, message=绑定帮助)


group_list = {}
group_add = {}

# @on_notice('group_decrease')
# async def group_member_decrease(session:NoticeSession):
#     ev=session.event
Exemple #12
0
from datetime import *
import string
import random
from . import util

import nonebot
from quart import request, Blueprint, jsonify, render_template

from hoshino import Service, priv

sv = Service('homework_',
             manage_priv=priv.SUPERUSER,
             enable_on_default=True,
             visible=False)
auth = Blueprint('auth',
                 __name__,
                 url_prefix='/auth',
                 template_folder="./vue",
                 static_folder='./vue',
                 static_url_path='')
bot = nonebot.get_bot()
app = bot.server_app

manage_password = '******'  # 管理密码请修改


@auth.route('/')
async def index():
    return await render_template("index.html")

Exemple #13
0
import random
import os
import requests
import math
import re
import subprocess
import time

from nonebot import MessageSegment
import hoshino
from hoshino import R, Service, priv, util, Thread
from nonebot import NoticeSession

sv = Service('groupchat', enable_on_default=True)
lmt = util.DailyNumberLimiter(5)


@sv.on_fullmatch('迫害龙王')
async def who_is_longwang(bot, ev):
    gid = ev.group_id
    img_path = R.img('longwang/').path
    data = await bot.get_group_honor_info(group_id=gid, type='talkative')
    talkative = data['current_talkative']
    uid = talkative['user_id']
    files = os.listdir(img_path)
    filename = random.choice(files)
    img = R.img('longwang/', filename)
    at = MessageSegment.at(uid)
    msg = f'{at}\n{img.cqcode}'
    await bot.send(ev, msg)
Exemple #14
0
from hoshino import Service,CommandSession,Privilege as Priv
from hoshino.util import DailyNumberLimiter

_max = 1
_lmt = DailyNumberLimiter(_max)
EXCEED_NOTICE = f'您今天已经喝过{_max}杯了,请明早5点后再来!'
sv=Service('feedback',enable_on_default=True,visible=False,manage_priv=Priv.SUPERUSER)
@sv.on_command('来杯咖啡')
async def feedback(session:CommandSession):
    uid = session.ctx['user_id']
    if not _lmt.check(uid):
        session.finish(EXCEED_NOTICE, at_sender=True)
    coffee = session.bot.config.SUPERUSERS[0]
    text = session.current_arg
    if not text:
        await session.send(f"来杯咖啡[空格]后输入您要反馈的内容~", at_sender=True)
    else:
        await session.bot.send_private_msg(self_id=session.ctx['self_id'], user_id=coffee, message=f'Q{uid}@群{session.ctx["group_id"]}\n{text}')
        await session.send(f'您的反馈已发送!\n=======\n{text}', at_sender=True)
        _lmt.increase(uid)
Exemple #15
0
import hoshino
from hoshino import Service
from hoshino.typing import NoticeSession

sv1 = Service('group-leave-notice', help_='退群通知')


@sv1.on_notice('group_decrease.leave')
async def leave_notice(session: NoticeSession):
    await session.send(f"{session.ctx['user_id']}跑了。")


sv2 = Service('group-welcome', help_='入群欢迎')


@sv2.on_notice('group_increase')
async def increace_welcome(session: NoticeSession):

    if session.event.user_id == session.event.self_id:
        return  # ignore myself

    welcomes = hoshino.config.groupmaster.increase_welcome
    gid = session.event.group_id
    if gid in welcomes:
        await session.send(welcomes[gid], at_sender=True)
    # elif 'default' in welcomes:
    #     await session.send(welcomes['default'], at_sender=True)
Exemple #16
0
    #         "damage":12345,
    #         "name":"QQ名"
    #     }
    #     }
}

boss_HP = {
    # "QQ群号":boss生命值
}

damage_ranking = {}

TXT_LEN = 12


sv = Service("筛刀")

help_txt = '''
公会战筛刀插件
[开始筛刀]           清空以前的筛刀数据
[筛刀 伤害值 @群友]  把筛刀数据报给机器人,如果手里有多个账号可以用@代报,自己的筛刀不需要@
[筛刀信息]           显示现在的筛刀信息
[结算 编号]          提醒筛刀信息里某人结算出刀,编号是筛刀信息里的编号
[结束筛刀]           清空当前筛刀数据

注意筛刀信息没有做持久化,如果筛刀过程中机器人重启会丢失当前筛刀数据
筛刀时会读取出刀数据获取boss当前生命值,所以当前公会战至少要报过一刀有出刀数据才行
注意新创建的公会有时候会获取不到apikey
'''

Exemple #17
0
import random
from hoshino import Service, R
from hoshino.typing import CQEvent
from hoshino.util import DailyNumberLimiter

sv = Service('pcr-login-bonus', bundle='pcr娱乐', help_='[@キャル签到] 给主さま盖章章')

lmt = DailyNumberLimiter(1)
login_presents = [
    '扫荡券×5',  '卢币×1000', '普通EXP药水×5',  '宝石×50',  '玛那×3000',
    '扫荡券×10', '卢币×1500', '普通EXP药水×15', '宝石×80',  '白金转蛋券×1',
    '扫荡券×15', '卢币×2000', '上级精炼石×3',   '宝石×100', '白金转蛋券×1',
]
todo_list = [
    '找伊绪老师上课',
    '给宫子买布丁',
    '和真琴寻找伤害优衣的人',
    '找镜哥探讨女装',
    '跟吉塔一起登上骑空艇',
    '和霞一起调查伤害优衣的人',
    '和佩可小姐一起吃午饭',
    '找小小甜心玩过家家',
    '帮碧寻找新朋友',
    '去真步真步王国',
    '找镜华补习数学',
    '陪胡桃排练话剧',
    '和初音一起午睡',
    '成为露娜的朋友',
    '帮铃莓打扫咲恋育幼院',
    '和静流小姐一起做巧克力',
    '去伊丽莎白农场给栞小姐送书',
from hoshino import Service, get_bot
from PIL import Image
from io import BytesIO

import os
import json
import time
import base64

sv = Service("原神每日素材提醒")

FILE_PATH = os.path.dirname(__file__)

group_list = []


def save_group_list():
    with open(os.path.join(FILE_PATH, 'group_list.json'),
              'w',
              encoding='UTF-8') as f:
        json.dump(group_list, f, ensure_ascii=False)


# 检查group_list.json是否存在,没有创建空的
if not os.path.exists(os.path.join(FILE_PATH, 'group_list.json')):
    save_group_list()

# 读取group_list.json的信息
with open(os.path.join(FILE_PATH, 'group_list.json'), 'r',
          encoding='UTF-8') as f:
    group_list = json.load(f)
Exemple #19
0
room_states = {}
all_user_name ={}
isOnChecking = False
bilibiliCookie = ''

sv_help = '''
- 订阅动态+空格+需要订阅的UID+空格
- 取消订阅动态+空格+需要取消订阅的UID
- 重新载入动态推送配置
'''.strip()

sv = Service(
    name = 'B站动态',  #功能名
    use_priv = priv.NORMAL, #使用权限   
    manage_priv = priv.ADMIN, #管理权限
    visible = True, #False隐藏
    enable_on_default = False, #是否默认启用
    bundle = '订阅', #属于哪一类
    help_ = sv_help #帮助文本
    )

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

async def broadcast(msg,groups=None,sv_name=None):
    bot = nonebot.get_bot()
    #当groups指定时,在groups中广播;当groups未指定,但sv_name指定,将在开启该服务的群广播
    svs = Service.get_loaded_services()
Exemple #20
0
from nonebot import *
from . import util, api, dupan_link, share, ru
from hoshino import Service  # 如果使用hoshino的分群管理取消注释这行

#

# 初始化配置文件
config = util.get_config()

# 初始化nonebot
_bot = get_bot()

sv = Service('网盘解析',
             visible=False,
             enable_on_default=False,
             bundle='网盘解析',
             help_='''
暂不使用
'''.strip())


# 如果使用hoshino的分群管理取消注释这行 并注释下一行的 @_bot.on_message("group")
# @_bot.on_message  # nonebot使用这
async def pan_main(*params):
    bot, ctx = (_bot, params[0]) if len(params) == 1 else params

    msg = str(ctx['message']).strip()
    # 获取下载直链
    keyword = util.get_msg_keyword(config.comm.keyword, msg, True)
    if keyword:
        try:
Exemple #21
0
import typing

from aiocqhttp.message import MessageSegment

from hoshino import Service

from .search_netease_cloud_music import search as search163
from .search_qq_music import search as searchqq

sv = Service('music',
             enable_on_default=True,
             visible=True,
             help_="[点歌 好日子]搜索歌曲",
             bundle='pcr娱乐')

temp = {}


@sv.on_prefix(['选歌', '选择歌', '选择歌曲'])
async def choose_song(bot, ev):
    key = f'{ev.group_id}-{ev.user_id}'
    if key not in temp:
        await bot.send(ev, '你还没有点歌呢!', at_sender=True)
        return
    song_dict = temp[key]
    song_idx = []
    for msg_seg in ev.message:
        if msg_seg.type == 'text' and msg_seg.data['text']:
            song_idx.append(msg_seg.data['text'].strip())
    if not song_idx:
        await bot.send(ev, '你想听什么呀?', at_sender=True)
Exemple #22
0
import json

import datetime
import hoshino
import re
import os
import random
import requests

CHARA_DATA_DIR = "./hoshino/modules/priconne/birthday/unitdata.json"  # 请自行修改
CHARA_DATA_API = "https://api.purinbot.cn/chara"
MAIN_DATA_SOURCE = 1  # 首选角色数据源:0.本地数据 1.在线api(不用手动更新数据)
UPDATE_LOCAL_DATA = ('更新本地数据')  # 更新本地角色数据的命令

bdrm = Service('pcr-birthday-reminder',
               enable_on_default=True,
               help_='生日提醒',
               bundle='pcr订阅')
svbdsrh = Service('pcr-birthday-search',
                  bundle='pcr娱乐',
                  help_='''
谁的生日是+日期 看看这天哪位老婆过生日
谁的生日是今天 看看今天哪位老婆过生日   
角色+生日是哪天 看看老婆哪天过生日
【如果你的Bot昵称设置成了PCR角色名称,请在搜索角色生日时重复一次角色名称】
'''.strip())


def download_chara_dara():
    try:
        chara_data = requests.request('GET', CHARA_DATA_API, timeout=5).json()
    except requests.exceptions.ConnectTimeout:
Exemple #23
0
    切噜词均以'切'开头,可用字符集为`CHERU_SET`

    L_cheru = {W_cheru ∪ `\\W`}*
    切噜语由切噜词与标点符号连接而成
"""

import re
from itertools import zip_longest

from nonebot.message import escape

from hoshino import Service
from hoshino.typing import CQEvent

sv = Service('pcr-cherugo', bundle='pcr娱乐', help_='''
[切噜一下] 转换为切噜语
[切噜~♪切啰巴切拉切蹦切蹦] 切噜语翻译
'''.strip())

CHERU_SET = '切卟叮咧哔唎啪啰啵嘭噜噼巴拉蹦铃'
CHERU_DIC = {c: i for i, c in enumerate(CHERU_SET)}
ENCODING = 'gb18030'
rex_split = re.compile(r'\b', re.U)
rex_word = re.compile(r'^\w+$', re.U)
rex_cheru_word: re.Pattern = re.compile(rf'切[{CHERU_SET}]+', re.U)


def grouper(iterable, n, fillvalue=None):
    args = [iter(iterable)] * n
    return zip_longest(*args, fillvalue=fillvalue)

from .gacha import Gacha

try:
    import ujson as json
except:
    import json


sv_help = '''
[星乃来发十连] 转蛋模拟
[星乃来发单抽] 转蛋模拟
[星乃来一井] 4w5钻!
[查看卡池] 模拟卡池&出率
[切换卡池] 更换模拟卡池
'''.strip()
sv = Service('gacha', help_=sv_help, bundle='pcr娱乐')
jewel_limit = DailyNumberLimiter(6000)
tenjo_limit = DailyNumberLimiter(1)

JEWEL_EXCEED_NOTICE = f'您今天已经抽过{jewel_limit.max}钻了,欢迎明早5点后再来!'
TENJO_EXCEED_NOTICE = f'您今天已经抽过{tenjo_limit.max}张天井券了,欢迎明早5点后再来!'
POOL = ('MIX', 'JP', 'TW', 'BL')
DEFAULT_POOL = POOL[0]

_pool_config_file = os.path.expanduser('~/.hoshino/group_pool_config.json')
_group_pool = {}
try:
    with open(_pool_config_file, encoding='utf8') as f:
        _group_pool = json.load(f)
except FileNotFoundError as e:
    sv.logger.warning('group_pool_config.json not found, will create when needed.')
Exemple #25
0
from hoshino import aiorequests
import asyncio
from .queryapi import getprofile

sv_help = '''
[竞技场绑定 uid] 绑定竞技场排名变动推送(仅下降),默认双场均启用
[竞技场查询( uid)] 查询竞技场简要信息
[停止竞技场订阅] 停止战斗竞技场排名变动推送
[停止公主竞技场订阅] 停止公主竞技场排名变动推送
[启用竞技场订阅] 启用战斗竞技场排名变动推送
[启用公主竞技场订阅] 启用公主竞技场排名变动推送
[删除竞技场订阅] 删除竞技场排名变动推送绑定
[竞技场订阅状态] 查看排名变动推送绑定状态
'''.strip()

sv = Service('竞技场推送', help_=sv_help, bundle='pcr查询')

Inited = False
pcrprofile = None
binds = {}
arena_ranks = {}
grand_arena_ranks = {}
tr = None
#api_key = "" #在这里填写API KEY


@sv.on_fullmatch('jjc帮助', only_to_me=False)
async def send_jjchelp(bot, ev):
    await bot.send(ev, sv_help)

Exemple #26
0
        'reserve_days': 1
    }
}
url_valid = re.compile(
    r'^(?:http|ftp)s?://'  # http:// or https://
    r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  #domain...
    r'localhost|'  #localhost...
    r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  # ...or ip
    r'(?::\d+)?'  # optional port
    r'(?:/?|[/?]\S+)$',
    re.IGNORECASE)

sv = Service(
    '会战报告',
    visible=True,
    enable_on_default=True,
    bundle='会战报告',
    help_=
    '生成会战报告 [@用户] [API地址] : 生成会战报告\n生成离职报告 [@用户] [API地址] : 生成离职报告\n设置工会api API地址 : (需要管理员权限)为本群设置默认的Yobot工会API\n查看工会api : (需要管理员权限)查看本群设置的Yobot API\n清除工会api : (需要管理员权限)清除本群设置的Yobot API\n加入可选项[@用户]表示查看指定用户的报告,需要管理员权限'
)


# 单json文件储存全部群api会出现奇怪的bug 所以每个群使用一个独立文件
#读取群api
def load_group_api(group_id):
    config_file = os.path.join(os.path.dirname(__file__), 'data',
                               f'{group_id}.json')
    if not os.path.exists(config_file):
        return ""  # config file not found, return default config.
    try:
        with open(config_file, encoding='utf8') as f:
            config = json.load(f)
Exemple #27
0
import hoshino
from hoshino import Service, priv
from hoshino.typing import CQEvent
from hoshino.util import DailyNumberLimiter

sv_help = '''
- [来杯咖啡] 后接反馈内容 联系维护组 请不要反馈无意义的事情
'''.strip()

sv = Service(
    name='来杯咖啡',  #功能名
    use_priv=priv.NORMAL,  #使用权限   
    manage_priv=priv.SUPERUSER,  #管理权限
    visible=True,  #False隐藏
    enable_on_default=True,  #是否默认启用
    bundle='通用',  #属于哪一类
    help_=sv_help  #帮助文本
)


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


_max = 1
lmt = DailyNumberLimiter(_max)
EXCEED_NOTICE = f'您今天已经喝过{_max}杯了,请明早5点后再来!'


@sv.on_prefix('来杯咖啡')
Exemple #28
0
from nonebot import *
from . import query, util
from hoshino import Service  # 如果使用hoshino的分群管理取消注释这行

#
sv = Service('ys-user')  # 如果使用hoshino的分群管理取消注释这行
# 初始化配置文件
config = util.get_config()

# 初始化nonebot
_bot = get_bot()

db = util.init_db(config.cache_dir)


@sv.on_message('group'
               )  # 如果使用hoshino的分群管理取消注释这行 并注释下一行的 @_bot.on_message("group")
# @_bot.on_message  # nonebot使用这
async def main(*params):
    bot, ctx = (_bot, params[0]) if len(params) == 1 else params
    uid = ctx.user_id
    msg = str(ctx['message']).strip()
    keyword = util.get_msg_keyword(config.comm.player_uid, msg, True)
    if isinstance(keyword, str):
        if not keyword:

            info = db.get(uid, {})
            if not info:
                return await bot.send(
                    ctx, '请输入游戏uid, 只支持b服或者官服, 只需要输入一次就会记住下次直接使用%s获取就好' %
                    config.comm.player_uid)
from hoshino import Service, priv, aiorequests
from hoshino.typing import MessageSegment, CQEvent
from hoshino.modules.priconne.news.spider import BaseSpider

from dataclasses import dataclass
from typing import List, Union
import hoshino, json, os

sv = Service('bili-search-spider',
             bundle='pcr订阅',
             help_='''
添加B站爬虫 <关键词> | 添加爬取关键词。每次添加一个,可添加多次
查看B站爬虫 | 查看当前爬取关键词列表
删除B站爬虫 <关键词> | 删除指定爬取关键词
'''.strip())


@dataclass
class Item:
    idx: Union[str, int]
    pic: str = ""
    content: str = ""

    def __eq__(self, other):
        return self.idx == other.idx


class BiliSearchSpider(BaseSpider):
    url = {}
    src_name = "B站爬虫"
    idx_cache = {}
Exemple #30
0
import random
from hoshino import Service, priv
from hoshino.typing import CQEvent
from hoshino.util import FreqLimiter
from .base import *
from .info import *
from .yobot import *

HELP_MSG = 'clanbattle_info\n公会战信息管理系统\n指令前缀:cbi\n指令表:帮助,总表,日总表,日出刀表,boss出刀表,个人出刀表,boss状态,预约,取消预约,查看预约,状态,检查成员,绑定,解除绑定,查看绑定,绑定未知成员,解除绑定未知成员,继续报刀,暂停报刀,重置报刀进度,重置推送进度,初始化,生成会战报告,生成离职报告\n默认不启用,启用请通知维护'

lmt = FreqLimiter(60)  #冷却时间60秒
process_lock = {}

sv = Service('自动报刀',
             visible=True,
             enable_on_default=False,
             bundle='自动报刀',
             help_=HELP_MSG)


@sv.on_prefix('cbi')
async def cbi(bot, ev: CQEvent):
    msg = ''
    user_id = ev.user_id
    target_id = 0
    for m in ev.message:
        if m.type == 'at' and m.data['qq'] != 'all':
            target_id = int(m.data['qq'])
    group_id = str(ev.group_id)
    args = ev.message.extract_plain_text().split()
    is_admin = priv.check_priv(ev, priv.ADMIN)