mirror of
				https://github.com/osmarks/autobotrobot
				synced 2025-10-31 07:53:00 +00:00 
			
		
		
		
	rdial, "cheese touch" role
This commit is contained in:
		
							
								
								
									
										23
									
								
								src/esoserver.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/esoserver.py
									
									
									
									
									
										Normal 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 | ||||||
| @@ -173,6 +173,12 @@ When you want to end a call, use hangup. | |||||||
|         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.") | ||||||
|  |     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.") |     @telephone.command(aliases=["call"], brief="Dial another telephone channel.") | ||||||
|     async def dial(self, ctx, address): |     async def dial(self, ctx, address): | ||||||
|         # basic checks - ensure this is a phone channel and has no other open calls |         # basic checks - ensure this is a phone channel and has no other open calls | ||||||
|   | |||||||
| @@ -265,7 +265,8 @@ extensions = ( | |||||||
|     "commands", |     "commands", | ||||||
|     "userdata", |     "userdata", | ||||||
|     "irc_link", |     "irc_link", | ||||||
|     "duckduckgo" |     "duckduckgo", | ||||||
|  |     "esoserver" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| # https://github.com/SawdustSoftware/simpleflake/blob/master/simpleflake/simpleflake.py | # https://github.com/SawdustSoftware/simpleflake/blob/master/simpleflake/simpleflake.py | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user