Esempio n. 1
0
File: read.py Progetto: yupix/ssm
	async def leave(self, ctx):
		create_wave(f'読み上げを終了します。お疲れ様でした。')
		source = discord.FFmpegPCMAudio(f"{Output_wav_name}")
		ctx.guild.voice_client.play(source)
		await asyncio.sleep(4)
		await ctx.voice_client.disconnect()
		logger.debug(f'ボイスチャンネル {ctx.voice_client.name} から退出しました')
Esempio n. 2
0
    async def rss(self, ctx, rss_url, *, args: check_args = None):
        if args is not None:
            if type(args) is not dict:
                await ctx.send(f'{args[1]}')
                return
            else:
                if '--max' in args:
                    logger.debug('test')
                    max_get_number = args.get('--max')
        else:
            max_get_number = None

        d = feedparser.parse(rss_url)
        embed = discord.Embed(title="取得したRSS情報")
        for i, entry in enumerate(d.entries):
            logger.debug(i)
            if max_get_number is not None:
                if f'{max_get_number}' != f'{i}':
                    if len(embed) < 1800:
                        embed.add_field(name=f"{entry.title}", value=f"{entry.link}", inline=True)
                    else:
                        await ctx.send(embed=embed)
                        embed = discord.Embed(title="取得したRSS情報")
                else:
                    await ctx.send(embed=embed)
                    return
            else:
                if len(embed) < 1800:
                    embed.add_field(name=f"{entry.title}", value=f"{entry.link}", inline=True)
                else:
                    await ctx.send(embed=embed)
                    embed = discord.Embed(title="取得したRSS情報")
        await ctx.send(embed=embed)
Esempio n. 3
0
File: main.py Progetto: yupix/ssm
def check_args(argument):
    split_argument = argument.lower().split(' ')
    hit = None
    args_list = {}
    for i in split_argument:
        if i == '--type' or i == '--test2' or i == '--max' or i == '-c' or i == '--register' or i == '--translate' or hit is not None:
            hit, args_list = add_list(hit, i, args_list)

    else:
        logger.debug(hit)
        if hit is not None:
            return '1', f'{i}には引数が必要です'
        else:
            print(args_list)
            return args_list
Esempio n. 4
0
File: read.py Progetto: yupix/ssm
	async def join(self, ctx):
		member = await ctx.guild.fetch_member(ctx.author.id)
		print(member.status)

		vc = ctx.author.voice.channel
		logger.debug(f'ボイスチャンネル {vc} に参加しました')
		create_wave(f'こんにちは! 読み上げを開始します。')
		source = discord.FFmpegPCMAudio(f"{Output_wav_name}")
		try:
			await vc.connect()
			await asyncio.sleep(3)
			ctx.guild.voice_client.play(source)
		except discord.ClientException:
			create_wave(f'既に参加しています')

			source = discord.FFmpegPCMAudio(f"{Output_wav_name}")
			ctx.guild.voice_client.play(source)
Esempio n. 5
0
File: main.py Progetto: yupix/ssm
async def bot_eew_loop():
    from ssm.cogs.eew import EewSendChannel
    url = "https://dev.narikakun.net/webapi/earthquake/post_data.json"
    result = requests.get(url).json()
    logger.debug(result)
    event_id = result['Head']['EventID']
    search_event_id = session.query(Eew).filter(
        Eew.event_id == event_id).first()
    if search_event_id is None:
        await db_manager.commit(Eew(event_id=event_id))
        eew_manager = EewSendChannel(bot)
        image_url = await eew_manager.get_nhk_image(
            result['Body']['Earthquake']['OriginTime'])
        search_eew_channel_list = session.query(EewChannel)
        for channel in search_eew_channel_list:
            logger.debug(f'{channel.channel_id}にEew情報を送信します')
            asyncio.ensure_future(
                eew_manager.main_title_send(channel, result, image_url))
Esempio n. 6
0
File: main.py Progetto: yupix/ssm
async def embed_send(ctx,
                     use_bot,
                     embed_type: int,
                     title: str,
                     subtitle: str,
                     color=None) -> discord.Message:
    if color is None:
        if embed_type == 0:  # 成功時
            embed_color = 0x8bc34a
        elif embed_type == 1:  # エラー発生時
            embed_color = 0xd32f2f
        else:
            embed_color = 0xb39ddb
    else:
        embed_color = color
    logger.debug(f'{embed_type}, {title}, {subtitle}')
    embed = discord.Embed(title=f'{title}',
                          description=f'{subtitle}',
                          color=embed_color)
    m = await use_bot.get_channel(ctx.message.channel.id).send(embed=embed)
    return m
Esempio n. 7
0
File: main.py Progetto: yupix/ssm
async def loop_bot_task():
    from ssm.cogs.warframe import get_warframe_fissures_api, fissure_tier_conversion, warframe_fissures_embed, mission_eta_conversion

    async def fissure_check():
        for fissure in session.query(WarframeFissuresDetail).order_by(
                WarframeFissuresDetail.tier):
            if message.detail_id == fissure.id:
                return True, fissure
            else:
                message_search_result = False
        return message_search_result, fissure

    # APIから情報を取得
    fissure_list = get_warframe_fissures_api()
    if fissure_list is None:  # Json形式ではなかった場合用
        return
    for warframe_fissure_id in session.query(WarframeFissuresId).all():
        for fissures in fissure_list:
            search_warframe_fissure_detail = session.query(
                WarframeFissuresDetail).filter(
                    WarframeFissuresDetail.api_id ==
                    f'{warframe_fissure_id.api_id}').first()
            if warframe_fissure_id.api_id != fissures[5]:
                await db_manager.commit(setattr(search_warframe_fissure_detail,
                                                'status', 'True'),
                                        commit_type='update',
                                        show_commit_log=False)
            else:
                await db_manager.commit(setattr(search_warframe_fissure_detail,
                                                'status', 'False'),
                                        commit_type='update',
                                        show_commit_log=False)
                break

    # API側で期限切れになっている亀裂がないかを確認
    for i in fissure_list:
        if i[6] is not True:
            check_warframe_fissure_detail = session.query(
                WarframeFissuresDetail).filter(
                    WarframeFissuresDetail.api_id == f'{i[5]}').first()
            if not check_warframe_fissure_detail or check_warframe_fissure_detail.api_id != f'{i[5]}':
                await db_manager.commit(WarframeFissuresId(api_id=f'{i[5]}'),
                                        show_commit_log=False)
                star_name = str(re.findall("(?<=\().+?(?=\))", i[0])).replace(
                    '{',
                    '').replace('}',
                                '').replace('[',
                                            '').replace(']',
                                                        '').replace('\'', '')
                await db_manager.commit(WarframeFissuresDetail(
                    api_id=f'{i[5]}',
                    node=f'{i[0]}',
                    enemy=f'{i[2]}',
                    type=f'{i[1]}',
                    tier=f'{i[3]}',
                    tier_original=f'{fissure_tier_conversion(i[3])}',
                    star_name=star_name,
                    eta=f'{i[4]}',
                    status=f'{i[6]}'),
                                        show_commit_log=False)
            else:
                await db_manager.commit(setattr(check_warframe_fissure_detail,
                                                'eta', f'{i[4]}'),
                                        commit_type='update',
                                        show_commit_log=False)
                await db_manager.commit(setattr(check_warframe_fissure_detail,
                                                'status', f'{i[6]}'),
                                        commit_type='update',
                                        show_commit_log=False)

    # 新しい亀裂が登録されてるチャンネルに送信されてない場合は送信
    for fissure_id in session.query(WarframeFissuresDetail).order_by(
            WarframeFissuresDetail.tier):
        check_already_fissure_message = session.query(
            WarframeFissuresMessage).filter(
                WarframeFissuresMessage.detail_id == fissure_id.id).first()
        if not check_already_fissure_message:
            for fissure_channel in session.query(
                    WarframeFissuresChannel).all():
                channel = bot.get_channel(int(fissure_channel.channel_id))
                embed = warframe_fissures_embed(
                    fissure_id.node, fissure_id.type, fissure_id.enemy,
                    fissure_tier_conversion(fissure_id.tier),
                    mission_eta_conversion(fissure_id.eta))
                send_embed = await channel.send(embed=embed)
                await db_manager.commit(WarframeFissuresMessage(
                    detail_id=fissure_id.id,
                    message_id=send_embed.id,
                    channel_id=send_embed.channel.id),
                                        show_commit_log=False)
                break
    for message in session.query(WarframeFissuresMessage).order_by(
            WarframeFissuresMessage.id):
        message_search_result, fissure = await fissure_check()
        channel = bot.get_channel(int(message.channel_id))
        get_message = await channel.fetch_message(int(message.message_id))
        if bool(strtobool(fissure.status)) is True:
            logger.debug(f'亀裂のAPI ID: {fissure.api_id} この亀裂は終了してる')
            embed = warframe_fissures_embed(
                fissure.node, fissure.type, fissure.enemy,
                fissure_tier_conversion(fissure.tier), '終了済み')
        else:
            logger.debug(f'亀裂のAPI ID: {fissure.api_id} この亀裂は終了していない')
            embed = warframe_fissures_embed(
                fissure.node, fissure.type, fissure.enemy,
                fissure_tier_conversion(fissure.tier),
                mission_eta_conversion(fissure.eta))
        await get_message.edit(embed=embed)
    # データに登録されている亀裂が期限切れになっていないかを確認
    for test in session.query(WarframeFissuresDetail).all():
        if bool(strtobool(test.status)) is True:
            await db_manager.commit(session.delete(
                session.query(WarframeFissuresId).filter(
                    WarframeFissuresId.api_id == f'{test.api_id}').first()),
                                    commit_type='delete',
                                    show_commit_log=False)
Esempio n. 8
0
File: level.py Progetto: yupix/ssm
 async def on_message(self, ctx):
     if ctx.author.bot:
         return
     logger.debug('作成中')
Esempio n. 9
0
File: level.py Progetto: yupix/ssm
 async def profile(self, ctx, arg):
     logger.debug('作成中')