Beispiel #1
0
async def register(ctx):
    member = Member(ctx.author)
    if member.exist_db():
        await ctx.channel.send("이미 등록된 사용자입니다.")
    else:
        member.add_db()
        await ctx.channel.send("등록되었습니다.")
Beispiel #2
0
async def give_point(ctx, user: discord.Member, point: int):
    if point <= 0: return

    member_send = Member(ctx.author)
    member_receive = Member(user)
    if not (member_send.exist_db() and member_receive.exist_db()):
        await ctx.channel.send("등록되지 않은 사용자입니다.")
        return

    if member_send.get_point() < point:
        await ctx.channel.send("점수가 부족합니다.")
        return

    member_send.give_point(member_receive, point)
    await ctx.channel.send("짜잔! {:s}님이 {:s}님에게 {:d}점을 선물했습니다.".format(
        member_send.mention(), member_receive.mention(), point))
    return
Beispiel #3
0
async def point(ctx, arg=None):
    if arg == None: user = ctx.author
    else: user = await commands.MemberConverter().convert(ctx, arg)

    member = Member(user)

    if not member.exist_db():
        await ctx.channel.send("등록되지 않은 사용자입니다.")
        return

    await ctx.channel.send("{:s}님의 날갱점수는 {:d}점입니다. {:d}연속 출석 중입니다.".format(
        member.name, member.get_point(), member.get_combo()))
    return
Beispiel #4
0
async def api_point_add(ctx, user: discord.Member, delta: int):
    member = Member(user)
    if not member.exist_db():
        await ctx.channel.send("등록되지 않은 사용자입니다.")
        return
    prev_point = member.get_point()
    if (prev_point + delta < 0):
        await ctx.send("점수가 부족합니다.")
        return
    member.set_point(prev_point + delta)
    if (delta >= 0):
        await ctx.send(
            f"{user.display_name}에게 {delta}점이 추가되었습니다. 이제 {member.get_point()}점입니다."
        )
    else:
        await ctx.send(
            f"{user.display_name}이 {-delta}점 잃었습니다. 이제 {member.get_point()}점입니다."
        )
    return
Beispiel #5
0
async def nalgang(ctx, *, arg=""):
    member = Member(ctx.author)
    logger.info(
        f"Querying user (id={member.id}, guild={member.guild})'s nalgang...")
    if not member.exist_db():
        await ctx.channel.send("등록되지 않은 사용자입니다.")
        return

    msg = arg
    if len(msg) > 280: msg = msg[:280]

    message_time = ctx.message.created_at.replace(tzinfo=pytz.utc).astimezone(
        pytz.timezone(timezone))
    result = member.nalgang(msg, present_time=message_time)

    if result == None:
        await ctx.channel.send("{:s}님은 이미 날갱되었습니다.".format(member.name))
    else:
        point, combo_point = result
        await ctx.channel.send("{:s}님이 날갱해서 {:d}점을 얻었습니다!".format(
            member.name, point))
        if combo_point != 0:
            await ctx.channel.send("와! {:s}님이 전근으로 {:d}점을 얻었습니다!".format(
                member.name, combo_point))

    attendance_info = get_all_attendance_info(member.guild)
    description = ""
    for index, info in enumerate(attendance_info):
        name = discord.utils.escape_markdown(
            ctx.guild.get_member(info[0]).display_name)
        msg = info[1]
        description += str(index + 1) + ". " + name + ": " + msg + "\n"

    embed = discord.Embed(title="오늘의 날갱", description=description)
    await ctx.channel.send(embed=embed)
    return