better logging
This commit is contained in:
parent
8eaa321840
commit
148302ac29
@ -15,7 +15,7 @@ Features:
|
||||
- Kick users with optional reasons.
|
||||
- Ban and unban users.
|
||||
|
||||
Author: Zodiac
|
||||
Author: Zodiac (Modified for verbose logging by bot.log)
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
@ -46,8 +46,10 @@ class VoicePlugin:
|
||||
"""
|
||||
nick = args.get('<nick>')
|
||||
if nick:
|
||||
self.bot.log.info("Request to grant voice to %s in %s", nick, target)
|
||||
await self.give_voice(target, nick)
|
||||
else:
|
||||
self.bot.log.info("Request to grant voice to all users in %s", target)
|
||||
await self.give_voice_all(target)
|
||||
|
||||
@command(permission='admin')
|
||||
@ -60,8 +62,10 @@ class VoicePlugin:
|
||||
"""
|
||||
nick = args.get('<nick>')
|
||||
if nick:
|
||||
self.bot.log.info("Request to remove voice from %s in %s", nick, target)
|
||||
await self.remove_voice(target, nick)
|
||||
else:
|
||||
self.bot.log.info("Request to remove voice from all users in %s", target)
|
||||
await self.remove_voice_all(target)
|
||||
|
||||
async def give_voice(self, target, nick):
|
||||
@ -72,6 +76,7 @@ class VoicePlugin:
|
||||
target (str): The IRC channel.
|
||||
nick (str): The nickname of the user.
|
||||
"""
|
||||
self.bot.log.info("Granting voice to user %s in channel %s", nick, target)
|
||||
self.bot.send(f'MODE {target} +v {nick}')
|
||||
|
||||
async def remove_voice(self, target, nick):
|
||||
@ -82,6 +87,7 @@ class VoicePlugin:
|
||||
target (str): The IRC channel.
|
||||
nick (str): The nickname of the user.
|
||||
"""
|
||||
self.bot.log.info("Removing voice from user %s in channel %s", nick, target)
|
||||
self.bot.send(f'MODE {target} -v {nick}')
|
||||
|
||||
async def give_voice_all(self, target):
|
||||
@ -91,9 +97,11 @@ class VoicePlugin:
|
||||
Args:
|
||||
target (str): The IRC channel.
|
||||
"""
|
||||
self.bot.log.info("Granting voice to all non-voiced users in channel %s", target)
|
||||
names = await self.bot.async_cmds.names(target)
|
||||
for user in names['names']:
|
||||
if not user.startswith(("+", "@")): # Ignore voiced/opped users
|
||||
self.bot.log.info("Granting voice to user %s", user)
|
||||
self.bot.send(f'MODE {target} +v {user}')
|
||||
await asyncio.sleep(0.07) # Prevent server flooding
|
||||
|
||||
@ -104,10 +112,13 @@ class VoicePlugin:
|
||||
Args:
|
||||
target (str): The IRC channel.
|
||||
"""
|
||||
self.bot.log.info("Removing voice from all voiced users in channel %s", target)
|
||||
names = await self.bot.async_cmds.names(target)
|
||||
for user in names['names']:
|
||||
if user.startswith("+"): # Only devoice voiced users
|
||||
self.bot.send(f'MODE {target} -v {user.lstrip("+")}')
|
||||
actual_user = user.lstrip("+")
|
||||
self.bot.log.info("Removing voice from user %s", actual_user)
|
||||
self.bot.send(f'MODE {target} -v {actual_user}')
|
||||
await asyncio.sleep(0.07) # Prevent server flooding
|
||||
|
||||
|
||||
@ -135,6 +146,7 @@ class KickPlugin:
|
||||
nick = args.get('<nick>')
|
||||
reason = args.get('<reason>') or 'Kicked by admin'
|
||||
if nick:
|
||||
self.bot.log.info("Request to kick user %s from channel %s for reason: %s", nick, target, reason)
|
||||
await self.kick_user(target, nick, reason)
|
||||
|
||||
async def kick_user(self, target, nick, reason):
|
||||
@ -146,6 +158,7 @@ class KickPlugin:
|
||||
nick (str): The nickname of the user.
|
||||
reason (str): The reason for kicking the user.
|
||||
"""
|
||||
self.bot.log.info("Kicking user %s from channel %s", nick, target)
|
||||
self.bot.send(f'PRIVMSG ChanServ :KICK {target} {nick} {reason}')
|
||||
|
||||
|
||||
@ -172,6 +185,7 @@ class BanPlugin:
|
||||
"""
|
||||
nick = args.get('<nick>')
|
||||
if nick:
|
||||
self.bot.log.info("Request to ban user %s from channel %s", nick, target)
|
||||
await self.ban_user(target, nick)
|
||||
|
||||
@command(permission='admin')
|
||||
@ -184,6 +198,7 @@ class BanPlugin:
|
||||
"""
|
||||
nick = args.get('<nick>')
|
||||
if nick:
|
||||
self.bot.log.info("Request to unban user %s from channel %s", nick, target)
|
||||
await self.unban_user(target, nick)
|
||||
|
||||
async def ban_user(self, target, nick):
|
||||
@ -194,6 +209,7 @@ class BanPlugin:
|
||||
target (str): The IRC channel.
|
||||
nick (str): The nickname of the user.
|
||||
"""
|
||||
self.bot.log.info("Banning user %s in channel %s", nick, target)
|
||||
self.bot.send(f'MODE {target} +b {nick}')
|
||||
|
||||
async def unban_user(self, target, nick):
|
||||
@ -204,4 +220,5 @@ class BanPlugin:
|
||||
target (str): The IRC channel.
|
||||
nick (str): The nickname of the user.
|
||||
"""
|
||||
self.bot.log.info("Unbanning user %s in channel %s", nick, target)
|
||||
self.bot.send(f'MODE {target} -b {nick}')
|
||||
|
Loading…
Reference in New Issue
Block a user