mirror of
https://github.com/osmarks/autobotrobot
synced 2025-02-07 04:30:02 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
8e03efc18f
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@ config.toml
|
|||||||
bot-data.json
|
bot-data.json
|
||||||
__pycache__
|
__pycache__
|
||||||
data.sqlite3
|
data.sqlite3
|
||||||
ts.py
|
ts.py
|
||||||
|
deploy.sh
|
13
requirements.txt
Normal file
13
requirements.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# TODO
|
||||||
|
pytio==0.3.1
|
||||||
|
aiohttp==3.8.3
|
||||||
|
aiosqlite==0.17.0
|
||||||
|
nextcord==2.0.0b4
|
||||||
|
numpy==1.23
|
||||||
|
prometheus-async==19.2.0
|
||||||
|
prometheus-client==0.15.0
|
||||||
|
pydot==1.4.2
|
||||||
|
toml==0.10.2
|
||||||
|
requests==2.28.1
|
||||||
|
python-dateutil==2.8.2
|
||||||
|
irc==20.1.0
|
@ -100,6 +100,9 @@ DELETE FROM user_data WHERE guild_id IS NULL;
|
|||||||
""",
|
""",
|
||||||
"""
|
"""
|
||||||
ALTER TABLE links ADD COLUMN cause TEXT;
|
ALTER TABLE links ADD COLUMN cause TEXT;
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
ALTER TABLE telephone_config ADD COLUMN disabled INTEGER;
|
||||||
"""
|
"""
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ logging.basicConfig(level=logging.INFO, format="%(levelname)s %(asctime)s %(mess
|
|||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.members = True
|
intents.members = True
|
||||||
|
intents.presences = True
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or(config["prefix"]), description="AutoBotRobot, the most useless bot in the known universe." + util.config.get("description_suffix", ""),
|
bot = commands.Bot(command_prefix=commands.when_mentioned_or(config["prefix"]), description="AutoBotRobot, the most useless bot in the known universe." + util.config.get("description_suffix", ""),
|
||||||
|
@ -91,7 +91,7 @@ class Reminders(commands.Cog):
|
|||||||
async def send_by_dm(self, info, text):
|
async def send_by_dm(self, info, text):
|
||||||
user = self.bot.get_user(info["author_id"])
|
user = self.bot.get_user(info["author_id"])
|
||||||
if not user:
|
if not user:
|
||||||
user = await bot.fetch_user(info["author_id"])
|
user = await self.bot.fetch_user(info["author_id"])
|
||||||
if not user: raise Exception(f"user {info['author_id']} unavailable/nonexistent")
|
if not user: raise Exception(f"user {info['author_id']} unavailable/nonexistent")
|
||||||
if not user.dm_channel: await user.create_dm()
|
if not user.dm_channel: await user.create_dm()
|
||||||
await user.dm_channel.send(text)
|
await user.dm_channel.send(text)
|
||||||
|
@ -283,14 +283,14 @@ When you want to end a call, use hangup.
|
|||||||
except discord.Forbidden as f:
|
except discord.Forbidden as f:
|
||||||
logging.warn("Could not create webhook in #%s %s", ctx.channel.name, ctx.guild.name, exc_info=f)
|
logging.warn("Could not create webhook in #%s %s", ctx.channel.name, ctx.guild.name, exc_info=f)
|
||||||
await ctx.send("Webhook creation failed - please ensure permissions are available. This is not necessary but is recommended.")
|
await ctx.send("Webhook creation failed - please ensure permissions are available. This is not necessary but is recommended.")
|
||||||
await self.bot.database.execute("INSERT OR REPLACE INTO telephone_config VALUES (?, ?, ?, ?)", (num, ctx.guild.id, ctx.channel.id, webhook))
|
await self.bot.database.execute("INSERT OR REPLACE INTO telephone_config VALUES (?, ?, ?, ?, 0)", (num, ctx.guild.id, ctx.channel.id, webhook))
|
||||||
await self.bot.database.commit()
|
await self.bot.database.commit()
|
||||||
await ctx.send("Configured.")
|
await ctx.send("Configured.")
|
||||||
|
|
||||||
@telephone.command(aliases=["rcall"], brief="Dial another telephone channel.")
|
@telephone.command(aliases=["rcall"], brief="Dial another telephone channel.")
|
||||||
async def rdial(self, ctx):
|
async def rdial(self, ctx):
|
||||||
# TODO: this is not very performant
|
# TODO: this is not very performant
|
||||||
random = (await self.bot.database.execute_fetchone("SELECT id FROM telephone_config ORDER BY RANDOM()"))["id"]
|
random = (await self.bot.database.execute_fetchone("SELECT id FROM telephone_config WHERE disabled = 0 ORDER BY RANDOM()"))["id"]
|
||||||
await self.dial(ctx, random)
|
await self.dial(ctx, random)
|
||||||
|
|
||||||
@telephone.command(aliases=["call"], brief="Dial another telephone channel.")
|
@telephone.command(aliases=["call"], brief="Dial another telephone channel.")
|
||||||
@ -308,6 +308,9 @@ When you want to end a call, use hangup.
|
|||||||
|
|
||||||
# post embed in the receiving channel prompting people to accept/decline call
|
# post embed in the receiving channel prompting people to accept/decline call
|
||||||
recv_channel = self.bot.get_channel(recv_info["channel_id"])
|
recv_channel = self.bot.get_channel(recv_info["channel_id"])
|
||||||
|
if recv_channel is None:
|
||||||
|
await self.bot.database.execute("UPDATE telephone_config SET disabled = 1 WHERE id = ?", (address,))
|
||||||
|
return await ctx.send(embed=util.error_embed("Target channel no longer exists."))
|
||||||
_, call_message = await asyncio.gather(
|
_, call_message = await asyncio.gather(
|
||||||
ctx.send(embed=util.info_embed("Outgoing call", f"Dialing {address}...")),
|
ctx.send(embed=util.info_embed("Outgoing call", f"Dialing {address}...")),
|
||||||
recv_channel.send(embed=util.info_embed("Incoming call",
|
recv_channel.send(embed=util.info_embed("Incoming call",
|
||||||
@ -418,7 +421,7 @@ When you want to end a call, use hangup.
|
|||||||
seen_edges.add(edge)
|
seen_edges.add(edge)
|
||||||
seen.add(current)
|
seen.add(current)
|
||||||
(handle, tmppath) = tempfile.mkstemp(".png", "graphviz")
|
(handle, tmppath) = tempfile.mkstemp(".png", "graphviz")
|
||||||
graph.write_png(tmppath)
|
graph.write_png(tmppath, prog="neato")
|
||||||
try:
|
try:
|
||||||
await ctx.send(file=discord.File(handle, filename="out.png"))
|
await ctx.send(file=discord.File(handle, filename="out.png"))
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user