mirror of
https://github.com/osmarks/autobotrobot
synced 2025-01-30 17:14:45 +00:00
I forgot
weird telephone changes, helloboiseconds, I think IRC bridge fixes
This commit is contained in:
parent
66db1b344c
commit
d43e431c54
@ -102,7 +102,7 @@ async def initialize():
|
||||
def disconnect(conn, event):
|
||||
logging.warn("Disconnected from IRC, reinitializing")
|
||||
teardown()
|
||||
asyncio.create_task(initialize)
|
||||
asyncio.create_task(initialize())
|
||||
|
||||
# TODO: do better thing
|
||||
conn.add_global_handler("welcome", connect)
|
||||
@ -116,6 +116,6 @@ async def initialize():
|
||||
def setup(bot):
|
||||
asyncio.create_task(initialize())
|
||||
|
||||
def teardown(bot):
|
||||
def teardown(bot=None):
|
||||
if global_conn: global_conn.disconnect()
|
||||
if unlisten: unlisten()
|
||||
|
@ -182,33 +182,29 @@ When you want to end a call, use hangup.
|
||||
pass
|
||||
|
||||
|
||||
async def _find_recent(self, chs, query):
|
||||
async def find_recent(self, chs, query):
|
||||
one_week = timedelta(seconds=60*60*24*7)
|
||||
one_week_ago = datetime.now()-one_week
|
||||
one_week_ago = datetime.now() - one_week
|
||||
|
||||
found = collections.defaultdict(list)
|
||||
async def find_msgs(ch):
|
||||
# the parameters to history() here might need to be tweaked
|
||||
# somewhat, for more general usage
|
||||
for ch in chs:
|
||||
yield True, ch
|
||||
async for msg in ch.history(limit=None,after=one_week_ago):
|
||||
if query in msg.content.lower():
|
||||
found[ch].append(msg)
|
||||
await asyncio.gather(*(find_msgs(ch) for ch in chs))
|
||||
return found
|
||||
yield False, ch, msg
|
||||
|
||||
@telephone.command(brief="find recent messages in channels linked to this")
|
||||
@telephone.command(brief="Find recent messages in channels linked to this")
|
||||
@commands.check(util.extpriv_check)
|
||||
async def searchrecent(self, ctx, ch: discord.TextChannel, *, query):
|
||||
author = ctx.author
|
||||
chs = []
|
||||
for dest in eventbus.find_all_destinations(('discord',ch.id)):
|
||||
if dest[0] == 'discord':
|
||||
for dest in eventbus.find_all_destinations(("discord",ch.id)):
|
||||
if dest[0] == "discord":
|
||||
chs.append(self.bot.get_channel(dest[1]))
|
||||
|
||||
found = await self._find_recent(chs, query)
|
||||
found = await self.find_recent(chs, query)
|
||||
|
||||
out = ""
|
||||
for ch,ms in found.items():
|
||||
async for ch,ms in found.items():
|
||||
out += f"{ch.mention} (`#{ch.name}` in `{ch.guild.name}`)\n"
|
||||
for m in ms:
|
||||
u = m.author.name if m.author else None
|
||||
@ -220,7 +216,7 @@ When you want to end a call, use hangup.
|
||||
|
||||
return found
|
||||
|
||||
@telephone.command(brief="delete recent messages in channels linked to this")
|
||||
@telephone.command(brief="Delete recent messages in channels linked to this")
|
||||
@commands.check(util.extpriv_check)
|
||||
async def delrecent(self, ctx, ch: discord.TextChannel, *, query):
|
||||
author = ctx.author
|
||||
@ -262,7 +258,6 @@ When you want to end a call, use hangup.
|
||||
await author.send("done")
|
||||
|
||||
|
||||
|
||||
@telephone.command(brief="Generate a webhook")
|
||||
@commands.check(util.server_mod_check)
|
||||
async def init_webhook(self, ctx):
|
||||
|
@ -50,7 +50,8 @@ time_units = (
|
||||
# Wikipedia tells me this is a traditional Chinese timekeeping unit
|
||||
("ke",),
|
||||
("minutes", "m"),
|
||||
("seconds", "s")
|
||||
("seconds", "s"),
|
||||
("helloboiseconds", "hbseconds", "hbs")
|
||||
)
|
||||
|
||||
tu_mappings = {
|
||||
@ -60,7 +61,8 @@ tu_mappings = {
|
||||
"beelifespans": lambda: (random.randint(122, 152), "days"),
|
||||
"semesters": (18, "weeks"),
|
||||
"fortnights": (2, "weeks"),
|
||||
"ke": (864, "seconds")
|
||||
"ke": (864, "seconds"),
|
||||
"helloboiseconds": (1800, "seconds")
|
||||
}
|
||||
|
||||
fractional_tu_mappings = {
|
||||
|
Loading…
Reference in New Issue
Block a user