Exemplo n.º 1
0
@utils.arg_command("add")
def add(args, message):
    nicks = utils.m2list(args)
    if message.sender_nick == ADMIN and MASTER:
        for nick in nicks:
            if nick in pids:
                return f"{message.sender_nick}: {nick} is already in use!"
        for nick in nicks:
            pids[nick] = subprocess.Popen(
                f"python3 /home/mattf/projects/ircbots/cbbot.py {shlex.quote(nick)} '{message.channel}'",
                stdout=subprocess.PIPE,
                shell=True)


##################################################
# RUNNING THE BOT                                #
##################################################


async def onConnect(bot: IrcBot):
    for channel in CHANNELS:
        await bot.join(channel)
    await bot.send_message("Hello everyone !!!")


if __name__ == "__main__":
    utils.setLogging(LEVEL, LOGFILE)
    utils.setPrefix(PREFIX)
    bot = IrcBot(HOST, PORT, NICK, CHANNELS, PASSWORD)
    bot.runWithCallback(onConnect)
Exemplo n.º 2
0
                Color("CHESS BOT INITIALIZED", Color.light_green,
                      Color.black).str,
                channel,
            )
    else:
        await bot.send_message(
            Color("CHESS BOT INITIALIZED", Color.light_green, Color.black).str)

    while True:
        for nick in botState.invites:
            for channel in botState.invites[nick]:
                for against_nick in deepcopy(botState.invites[nick][channel]):
                    now = datetime.now().timestamp()
                    if (now - botState.invites[nick][channel][against_nick] >
                            EXPIRE_INVITE_IN):
                        botState.invites[nick][channel].pop(against_nick)
                        await bot.send_message(
                            f"<{against_nick}> Your game request to {nick} has expired!",
                            channel,
                        )
        await bot.sleep(0.5)


##################################################
# RUNNING THE BOT                                #
##################################################

if __name__ == "__main__":
    bot = IrcBot(HOST, PORT, NICK, CHANNELS, PASSWORD, tables=[db_handler])
    bot.runWithCallback(onRun)
Exemplo n.º 3
0
    while True:
        l = 1
        r = 14
        w = 15
        c = True  # Direction (true = right)
        while not waitForStart:
            await bot.send_message(
                Color(l * "  ", bg=Color.red).str +
                Color("          ", bg=Color.black).str +
                Color(r * "  ", bg=Color.red).str)
            if c:
                l += 1
                r = w - l
            else:
                l -= 1
                r = w - l
            if l == w or l == 1:
                c = not c
            await bot.sleep(.5)
        await bot.sleep(1)


##################################################
# RUNNING THE BOT                                #
##################################################

if __name__ == "__main__":
    utils.setLogging(LEVEL, LOGFILE)
    bot = IrcBot(HOST, PORT, NICK, CHANNELS, PASSWORD)
    bot.runWithCallback(mainLoop)
Exemplo n.º 4
0
        Message(
            m["nick"], message=f"{m['filename']} has been received!", is_private=True
        )
    )


@utils.custom_handler("dccreject")
def on_dcc_reject(**m):
    log(f"Rejected!!! {m=}")


async def on_run(bot: IrcBot):
    log("STARTED!")
    # Startup Setup
    # await bot.sleep(1)
    # await bot.send_raw(f"OPER {NICK} {PASSWORD}")


if __name__ == "__main__":
    bot = IrcBot(
        HOST,
        PORT,
        NICK,
        CHANNELS,
        password=PASSWORD,
        dcc_host=DCC_HOST,
        use_ssl=PORT == 6697,
        tables=[configs],
    )
    bot.runWithCallback(on_run)