rdial, "cheese touch" role

This commit is contained in:
osmarks 2021-04-14 22:44:16 +01:00
parent c80e6ae5e3
commit 8ae4fa22cb
3 changed files with 31 additions and 1 deletions

23
src/esoserver.py Normal file
View File

@ -0,0 +1,23 @@
import util
import random
import logging
import discord
import metrics
def setup(bot):
@bot.listen()
async def on_message(message):
if message.guild.id == util.config["esoserver"]["id"]:
for role in message.role_mentions:
if role.id == util.config["esoserver"]["transfer_role"]: # transfer the role from sender to other pinged person
if len(message.mentions) == 1:
await message.author.remove_roles(role, reason="untransfer unrole")
await message.mentions[0].add_roles(role, reason="transfer role")
return
for user in message.mentions:
for role in user.roles:
if role.id == util.config["esoserver"]["transfer_role"]: # transfer from pingee to pinger
await user.remove_roles(role, reason="untransfer unrole")
await message.author.add_roles(role, reason="transfer role")
return

View File

@ -173,6 +173,12 @@ When you want to end a call, use hangup.
await self.bot.database.commit()
await ctx.send("Configured.")
@telephone.command(aliases=["rcall"], brief="Dial another telephone channel.")
async def rdial(self, ctx):
# TODO: this is not very performant
random = (await self.bot.database.execute_fetchone("SELECT id FROM telephone_config ORDER BY RANDOM()"))["id"]
await self.dial(ctx, random)
@telephone.command(aliases=["call"], brief="Dial another telephone channel.")
async def dial(self, ctx, address):
# basic checks - ensure this is a phone channel and has no other open calls

View File

@ -265,7 +265,8 @@ extensions = (
"commands",
"userdata",
"irc_link",
"duckduckgo"
"duckduckgo",
"esoserver"
)
# https://github.com/SawdustSoftware/simpleflake/blob/master/simpleflake/simpleflake.py