114 lines
3.3 KiB
Python
Executable File
114 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Some administrative functions relating to the channel the bot is in. Note
|
|
that most of these will require the bot to have admin privileges in the
|
|
channel.
|
|
"""
|
|
import re
|
|
|
|
import module
|
|
from tools import op_level, configureHostMask
|
|
|
|
op = ['~', '!', '@', '%']
|
|
|
|
@module.require_chanmsg
|
|
@module.require_admin
|
|
@module.commands('kick')
|
|
@module.example(".kick faggot being a faggot")
|
|
def kick(bot, trigger):
|
|
"""
|
|
Kick a user from the channel.
|
|
"""
|
|
if bot.channels[trigger.channel].users[bot.nick].op_level not in op:
|
|
return bot.reply("I'm not a channel operator!")
|
|
if not trigger.group(2):
|
|
return bot.reply("Who do you want me to kick?")
|
|
|
|
target, _, reason = trigger.group(2).partition(" ")
|
|
if not reason:
|
|
reason = "Stop doing the bad."
|
|
|
|
if target == bot.nick:
|
|
return bot.reply("I can't let you do that.")
|
|
|
|
bot.kick(trigger.channel, target, reason)
|
|
|
|
|
|
@module.require_chanmsg
|
|
@module.require_admin
|
|
@module.commands('ban')
|
|
@module.example(".ban faggot")
|
|
def ban(bot, trigger):
|
|
"""
|
|
This give admins the ability to ban a user.
|
|
The bot must be a Channel Operator for this command to work.
|
|
"""
|
|
if bot.channels[trigger.channel].users[bot.nick].op_level not in op:
|
|
return bot.reply("I'm not a channel operator!")
|
|
if not trigger.group(2):
|
|
return bot.reply("Who do you want me to ban?")
|
|
|
|
banmask = configureHostMask(trigger.group(2))
|
|
bot.mode(trigger.channel, True, "b", mask=banmask)
|
|
|
|
|
|
@module.require_chanmsg
|
|
@module.require_admin
|
|
@module.commands('unban')
|
|
@module.example(".unban faggot")
|
|
def unban(bot, trigger):
|
|
"""
|
|
This give admins the ability to unban a user.
|
|
The bot must be a Channel Operator for this command to work.
|
|
"""
|
|
if bot.channels[trigger.channel].users[bot.nick].op_level not in op:
|
|
return bot.reply("I'm not a channel operator!")
|
|
if not trigger.group(2):
|
|
return bot.reply("Who do you want me to ban?")
|
|
|
|
banmask = configureHostMask(trigger.group(2))
|
|
bot.mode(trigger.channel, False, "b", mask=banmask)
|
|
|
|
|
|
@module.require_chanmsg
|
|
@module.require_admin
|
|
@module.commands('kickban')
|
|
def kickban(bot, trigger):
|
|
"""
|
|
This gives admins the ability to kickban a user.
|
|
The bot must be a Channel Operator for this command to work.
|
|
.kickban [#chan] user1 user!*@module.* get out of here
|
|
"""
|
|
if bot.channels[trigger.channel].users[bot.nick].op_level not in op:
|
|
return bot.reply("I'm not a channel operator!")
|
|
if not trigger.group(2):
|
|
return bot.reply("Who do you want me to ban?")
|
|
|
|
target, _, reason = trigger.group(2).partition(" ")
|
|
if not reason:
|
|
reason = "Stop doing the bad."
|
|
|
|
if target == bot.nick:
|
|
return bot.reply("I can't let you do that.")
|
|
|
|
banmask = configureHostMask(trigger.group(2).strip())
|
|
bot.mode(trigger.channel, False, "b", mask=banmask)
|
|
bot.kick(trigger.channel, target, reason)
|
|
|
|
|
|
@module.require_chanmsg
|
|
@module.require_admin
|
|
@module.commands('settopic')
|
|
@module.example(".settopic We're discussing penises, would you like to join?")
|
|
def settopic(bot, trigger):
|
|
"""
|
|
This gives ops the ability to change the topic.
|
|
The bot must be a Channel Operator for this command to work.
|
|
"""
|
|
if bot.channels[trigger.channel].users[bot.nick].op_level not in op:
|
|
return bot.reply("I'm not a channel operator!")
|
|
if not trigger.group(2):
|
|
return bot.reply("What do you want the topic set to?")
|
|
|
|
bot.topic(trigger.channel, trigger.group(2).strip())
|