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