def main(argv=sys.argv[1:]):
    argument_parser = argparse.ArgumentParser()
    # argument_parser.add_argument('--username', type=str,
    #         default='PiazzaBot', help='the bot\'s Keybase username')
    args = argument_parser.parse_args(argv)

    logger.info('keybase_piazza_bot starting')

    event_loop = asyncio.get_event_loop()

    piazza = Piazza()
    piazza.user_login() # login prompt
    cse220 = piazza.network(PIAZZA_NETWORK_ID)

    keybase_bot_handler = KeybaseBotHandler(piazza, cse220)
    keybase_bot = Bot(
        handler=keybase_bot_handler,
        loop=event_loop,
        # username=args.username,
    )
    future = keybase_bot.start({})

    event_loop.run_until_complete(future)
    event_loop.close()

    logger.info('keybase_piazza_bot exiting')
        storage(splitter)


    elif len(event.msg.content.text.body) < 40:
        wok = event.msg.content.text.body
        inputter = wok
        splitter = give()
        if sentencefind(inputter, splitter) == None:
            pass
        else:
            sentences = splitter[sentencefind(inputter, splitter)]

        await bot.chat.send(channel, sentences)




listen_options = {
    "local": True,
    "wallet": True,
    "dev": True,
    "hide-exploding": False,
    "filter_channel": None,
    "filter_channels": None,

}

bot = Bot(username="******", paperkey= "identify virtual arctic hotel recall already neutral card cabin promote federal romance lend", handler=handler)

asyncio.run(bot.start(listen_options))
Exemple #3
0
                await self.add(bot, team, issuer, secret)
                send_msg = "TOTP added for {}".format(issuer)
            except Exception as e:
                print(e)
            finally:
                await bot.chat.send(channel, send_msg)
            return

    async def handle_remove(self, bot, channel, team, msg, action):
        if len(msg) == 3:
            issuer = msg[2]
            # chat: "!totp remove <issuer>"
            send_msg = "No keys to remove for {}".format(issuer)
            try:
                await self.remove(bot, team, issuer)
                send_msg = "Removed TOTP keys for {}".format(issuer)
            except Exception as e:
                print(e)
            finally:
                await bot.chat.send(channel, send_msg)
            return


username = "******"

bot = Bot(username=username,
          paperkey=os.environ["KEYBASE_PAPERKEY"],
          handler=TotpHandler())

asyncio.run(bot.start({}))
Exemple #4
0
    async def __call__(self, bot, event):
        if event.msg.content.type != ContentType.TEXT:
            return
        channel = event.msg.channel
        if event.msg.content.text.body != "trigger":
            return
        # If you message 3 "trigger"s in rapid succession, the bot should
        # be done sending the alerts in ~5 seconds as opposed to 15 seconds.
        # BUT if you try this again with use_lock=True, it will stack the
        # requests and take the full 15 seconds.
        if self.use_lock:
            async with self.lock:
                await alert(bot, 5, channel)
        else:
            await alert(bot, 5, channel)


listen_options = {
    'filter-channel': {"name": "yourbot,someoneelse"}
}

loop = asyncio.get_event_loop()
bot = Bot(
    username="******",
    paperkey=os.environ['KEYBASE_PAPERKEY'],
    handler=Handler(use_lock=False),
    loop=loop,
)
loop.run_until_complete(bot.start(listen_options))
loop.close()
Exemple #5
0
    updated_bot_map = {}

    for prefix, bot_cls in BOT_MAP.items():
        aliases = []

        if isinstance(prefix, tuple):
            aliases.extend(prefix)
        else:
            aliases.append(prefix)

        bot = bot_cls(dbot)
        for alias in aliases:
            updated_bot_map[alias] = bot

    BOT_MAP = updated_bot_map


if __name__ == "__main__":
    dbot = discord.Client()
    kbbot = KBBot(handler=Handler())

    init_bots(dbot)

    loop = asyncio.get_event_loop()

    loop.create_task(dbot.start(os.environ["DISCORD_TOKEN"], bot=False))
    loop.create_task(kbbot.start({}))
    loop.create_task(forwarder(dbot, kbbot))

    loop.run_forever()