2019-05-25 20:40:06 +00:00
|
|
|
#--depends-on channel_access
|
|
|
|
#--depends-on check_mode
|
|
|
|
#--depends-on commands
|
|
|
|
#--depends-on config
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
from src import ModuleManager, utils
|
2016-04-18 15:50:19 +00:00
|
|
|
|
2018-09-30 12:28:26 +00:00
|
|
|
class UserNotFoundException(Exception):
|
|
|
|
pass
|
|
|
|
class InvalidTimeoutException(Exception):
|
|
|
|
pass
|
|
|
|
|
2019-06-28 22:16:05 +00:00
|
|
|
@utils.export("channelset", utils.IntSetting("highlight-spam-threshold",
|
|
|
|
"Set the number of nicknames in a message that qualifies as spam"))
|
|
|
|
@utils.export("channelset", utils.BoolSetting("highlight-spam-protection",
|
|
|
|
"Enable/Disable highlight spam protection"))
|
|
|
|
@utils.export("channelset", utils.BoolSetting("highlight-spam-ban",
|
|
|
|
"Enable/Disable banning highlight spammers instead of just kicking"))
|
|
|
|
@utils.export("channelset", utils.Setting("ban-format",
|
|
|
|
"Set ban format ($n = nick, $u = username, $h = hostname)",
|
|
|
|
example="*!$u@$h"))
|
2019-06-28 22:25:24 +00:00
|
|
|
@utils.export("serverset", utils.OptionsSetting("mute-method",
|
|
|
|
["qmode", "insp", "unreal"], "Set this server's method of muting users",
|
|
|
|
example="qmode"))
|
2018-09-27 11:08:07 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2019-04-26 06:26:33 +00:00
|
|
|
_name = "ChanOp"
|
2016-04-18 15:50:19 +00:00
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("timer.unban")
|
2018-09-30 12:28:26 +00:00
|
|
|
def _timer_unban(self, event):
|
2019-04-24 11:07:30 +00:00
|
|
|
server = self.bot.get_server_by_id(event["server_id"])
|
2019-06-27 19:52:32 +00:00
|
|
|
if server and event["channel_name"] in server.channels:
|
2018-11-11 12:34:22 +00:00
|
|
|
channel = server.channels.get(event["channel_name"])
|
2018-09-30 12:28:26 +00:00
|
|
|
channel.send_unban(event["hostmask"])
|
|
|
|
|
|
|
|
def _kick(self, server, channel, nickname, reason):
|
|
|
|
target_user = server.get_user(nickname)
|
|
|
|
if channel.has_user(target_user):
|
|
|
|
channel.send_kick(nickname, reason)
|
|
|
|
else:
|
|
|
|
raise UserNotFoundException("That user is not in this channel")
|
2019-01-30 21:02:12 +00:00
|
|
|
def _kick_command(self, event, channel, args_split):
|
|
|
|
target = args_split[0]
|
|
|
|
reason = " ".join(args_split[1:]) or None
|
|
|
|
|
|
|
|
try:
|
2019-01-30 21:03:21 +00:00
|
|
|
self._kick(event["server"], channel, target, reason)
|
2019-05-08 06:36:17 +00:00
|
|
|
except UserNotFoundException as e:
|
2019-01-30 21:02:12 +00:00
|
|
|
event["stderr"].write(str(e))
|
|
|
|
|
|
|
|
@utils.hook("received.command.kick", private_only=True, min_args=2)
|
|
|
|
def private_kick(self, event):
|
|
|
|
"""
|
|
|
|
:help: Kick a user from the current channel
|
|
|
|
:usage: <nickname> [reason]
|
|
|
|
:prefix: Kick
|
|
|
|
"""
|
|
|
|
channel = event["server"].channels.get(event["args_split"][0])
|
2019-06-15 17:42:14 +00:00
|
|
|
|
|
|
|
event["check_assert"](utils.Check("channel-access", channel, "kick"))
|
2019-06-14 16:23:22 +00:00
|
|
|
|
2019-01-30 21:02:12 +00:00
|
|
|
self._kick_command(event, channel, event["args_split"][1:])
|
2018-09-30 12:28:26 +00:00
|
|
|
|
2018-10-10 09:42:41 +00:00
|
|
|
@utils.hook("received.command.k", alias_of="kick")
|
|
|
|
@utils.hook("received.command.kick", channel_only=True, min_args=1)
|
2016-04-18 15:50:19 +00:00
|
|
|
def kick(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Kick a user from the current channel
|
|
|
|
:usage: <nickname> [reason]
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: kick
|
2018-10-04 10:05:43 +00:00
|
|
|
:prefix: Kick
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2019-01-30 21:02:12 +00:00
|
|
|
self._kick_command(event, event["target"], event["args_split"])
|
2016-04-18 15:50:19 +00:00
|
|
|
|
2018-07-19 13:39:10 +00:00
|
|
|
def _ban_format(self, user, s):
|
|
|
|
return s.replace("$n", user.nickname).replace("$u", user.username
|
|
|
|
).replace("$h", user.hostname)
|
2018-09-30 12:28:26 +00:00
|
|
|
def _ban_user(self, channel, ban, user):
|
|
|
|
if channel.has_user(user):
|
|
|
|
format = channel.get_setting("ban-format", "*!$u@$h")
|
|
|
|
hostmask_split = format.split("$$")
|
|
|
|
hostmask_split = [self._ban_format(user, s) for s in hostmask_split]
|
|
|
|
hostmask = "".join(hostmask_split)
|
|
|
|
if ban:
|
|
|
|
channel.send_ban(hostmask)
|
|
|
|
else:
|
|
|
|
channel.send_unban(hostmask)
|
|
|
|
return hostmask
|
2018-07-19 13:39:10 +00:00
|
|
|
else:
|
2018-09-30 12:28:26 +00:00
|
|
|
raise UserNotFoundException("That user is not in this channel")
|
|
|
|
|
|
|
|
def _ban(self, server, channel, ban, target):
|
|
|
|
target_user = server.get_user(target)
|
|
|
|
if channel.has_user(target_user):
|
2018-10-19 13:37:24 +00:00
|
|
|
return self._ban_user(channel, ban, target_user)
|
2018-09-30 12:28:26 +00:00
|
|
|
else:
|
|
|
|
if ban:
|
|
|
|
event["target"].send_ban(target)
|
|
|
|
else:
|
|
|
|
event["target"].send_unban(target)
|
|
|
|
return target
|
2018-09-26 17:27:17 +00:00
|
|
|
|
2019-01-30 21:02:12 +00:00
|
|
|
@utils.hook("received.command.ban", private_only=True, min_args=2)
|
|
|
|
def private_ban(self, event):
|
|
|
|
"""
|
|
|
|
:help: Ban a user/hostmask from the current channel
|
|
|
|
:usage: <channel> <nickname/hostmask>
|
|
|
|
"""
|
|
|
|
channel = event["server"].channels.get(event["args_split"][0])
|
2019-06-15 17:42:14 +00:00
|
|
|
|
|
|
|
event["check_assert"](utils.Check("channel-access", channel, "ban"))
|
2019-06-14 16:23:22 +00:00
|
|
|
|
2019-01-30 21:02:12 +00:00
|
|
|
self._ban(event["server"], channel, True, event["args_split"][1])
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.ban", channel_only=True, min_args=1)
|
2016-04-18 15:50:19 +00:00
|
|
|
def ban(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Ban a user/hostmask from the current channel
|
|
|
|
:usage: <nickname/hostmask>
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: ban
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 12:28:26 +00:00
|
|
|
self._ban(event["server"], event["target"], True,
|
|
|
|
event["args_split"][0])
|
|
|
|
|
|
|
|
def _temp_ban(self, event, accept_hostmask):
|
2018-10-03 12:22:37 +00:00
|
|
|
timeout = utils.from_pretty_time(event["args_split"][1])
|
2018-09-30 12:28:26 +00:00
|
|
|
if not timeout:
|
|
|
|
raise InvalidTimeoutException(
|
|
|
|
"Please provided a valid time above 0 seconds")
|
|
|
|
|
|
|
|
if accept_hostmask:
|
|
|
|
hostmask = self._ban(event["server"], event["target"], True,
|
|
|
|
event["args_split"][0])
|
2016-04-18 15:50:19 +00:00
|
|
|
else:
|
2018-09-30 12:28:26 +00:00
|
|
|
hostmask = self._ban_user(event["target"], True,
|
|
|
|
event["server"].get_user(event["args_split"][0]))
|
|
|
|
|
2018-10-12 17:07:23 +00:00
|
|
|
self.timers.add_persistent("unban", timeout,
|
2018-09-30 12:28:26 +00:00
|
|
|
server_id=event["server"].id,
|
|
|
|
channel_name=event["target"].name, hostmask=hostmask)
|
2018-10-10 09:42:41 +00:00
|
|
|
|
|
|
|
@utils.hook("received.command.tb", alias_of="tempban")
|
|
|
|
@utils.hook("received.command.tempban", channel_only=True, min_args=2)
|
2018-09-30 12:28:26 +00:00
|
|
|
def temp_ban(self, event):
|
2018-09-30 16:29:09 +00:00
|
|
|
"""
|
|
|
|
:help: Temporarily ban someone from the current channel
|
2019-01-29 17:37:14 +00:00
|
|
|
:usage: <nickname/hostmask> <time> [reason]
|
2018-09-30 16:29:09 +00:00
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: ban
|
2018-10-04 10:05:43 +00:00
|
|
|
:prefix: Tempban
|
2018-09-30 16:29:09 +00:00
|
|
|
"""
|
2018-09-30 12:28:26 +00:00
|
|
|
try:
|
|
|
|
self._temp_ban(event, True)
|
|
|
|
except InvalidTimeoutException as e:
|
|
|
|
event["stderr"].write(str(e))
|
2018-10-10 09:42:41 +00:00
|
|
|
|
|
|
|
@utils.hook("received.command.tkb", alias_of="tempkickban")
|
|
|
|
@utils.hook("received.command.tempkickban", channel_only=True,
|
2018-09-30 16:29:09 +00:00
|
|
|
min_args=2)
|
2018-09-30 12:28:26 +00:00
|
|
|
def temp_kick_ban(self, event):
|
2018-09-30 16:29:09 +00:00
|
|
|
"""
|
|
|
|
:help: Temporarily kick and ban someone from the current channel
|
2019-01-29 17:37:14 +00:00
|
|
|
:usage: <nickname> <time> [reason]
|
2018-09-30 16:29:09 +00:00
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: kickban
|
2018-10-04 10:05:43 +00:00
|
|
|
:prefix: TKB
|
2018-09-30 16:29:09 +00:00
|
|
|
"""
|
2018-09-30 12:28:26 +00:00
|
|
|
reason = " ".join(event["args_split"][2:]) or None
|
|
|
|
try:
|
|
|
|
self._temp_ban(event, False)
|
|
|
|
self._kick(event["server"], event["target"], event["args_split"][0],
|
|
|
|
reason)
|
|
|
|
except InvalidTimeoutException as e:
|
|
|
|
event["stderr"].write(str(e))
|
|
|
|
except UserNotFoundException as e:
|
|
|
|
event["stderr"].write(str(e))
|
|
|
|
|
2019-01-30 21:06:02 +00:00
|
|
|
@utils.hook("received.command.unban", private_only=True, min_args=2)
|
2019-01-30 21:07:03 +00:00
|
|
|
def private_unban(self, event):
|
2019-01-30 21:06:02 +00:00
|
|
|
"""
|
|
|
|
:help: Unban a user/hostmask from the current channel
|
|
|
|
:usage: <channel> <nickname/hostmask>
|
|
|
|
"""
|
|
|
|
channel = event["server"].channels.get(event["args_split"][0])
|
2019-06-15 17:42:14 +00:00
|
|
|
|
|
|
|
event["check_assert"](utils.Check("channel-access", channel, "ban"))
|
2019-06-14 16:23:22 +00:00
|
|
|
|
2019-01-30 21:06:02 +00:00
|
|
|
self._ban(event["server"], channel, False, event["args_split"][1])
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.unban", channel_only=True, min_args=1)
|
2018-07-19 13:39:10 +00:00
|
|
|
def unban(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Unban a user/hostmask from the current channel
|
|
|
|
:usage: <nickname/hostmask>
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: ban
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 12:28:26 +00:00
|
|
|
self._ban(event["server"], event["target"], False,
|
|
|
|
event["args_split"][0])
|
2016-04-18 15:50:19 +00:00
|
|
|
|
2018-10-10 09:42:41 +00:00
|
|
|
@utils.hook("received.command.kb", alias_of="kickban")
|
|
|
|
@utils.hook("received.command.kickban", channel_only=True, min_args=1)
|
2016-04-18 15:50:19 +00:00
|
|
|
def kickban(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Kick and ban a user from the current channel
|
|
|
|
:usage: <nickname> [reason]
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: kickban
|
2018-10-04 10:05:43 +00:00
|
|
|
:prefix: Kickban
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 12:28:26 +00:00
|
|
|
target = event["args_split"][0]
|
|
|
|
reason = " ".join(event["args_split"][1:]) or None
|
|
|
|
try:
|
|
|
|
self._ban(event["server"], event["target"], True, target)
|
|
|
|
self._kick(event["server"], event["target"], target, reason)
|
|
|
|
except UserNotFoundException as e:
|
|
|
|
event["stderr"].write(str(e))
|
2016-04-22 10:48:28 +00:00
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.op", channel_only=True)
|
2016-04-22 10:48:28 +00:00
|
|
|
def op(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Op a user in the current channel
|
|
|
|
:usage: [nickname]
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: op
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2016-07-05 11:17:22 +00:00
|
|
|
target = event["user"].nickname if not event["args_split"] else event[
|
|
|
|
"args_split"][0]
|
2019-02-18 14:56:25 +00:00
|
|
|
event["target"].send_mode("+o", [target])
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.deop", channel_only=True)
|
2016-05-17 13:51:47 +00:00
|
|
|
def deop(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Remove op from a user in the current channel
|
|
|
|
:usage: [nickname]
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: op
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2016-07-05 11:17:22 +00:00
|
|
|
target = event["user"].nickname if not event["args_split"] else event[
|
|
|
|
"args_split"][0]
|
2019-02-18 14:56:25 +00:00
|
|
|
event["target"].send_mode("-o", [target])
|
2018-09-26 17:27:17 +00:00
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.voice", channel_only=True)
|
2016-05-17 13:51:47 +00:00
|
|
|
def voice(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Voice a user in the current channel
|
|
|
|
:usage: [nickname]
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: voice
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2016-07-05 11:17:22 +00:00
|
|
|
target = event["user"].nickname if not event["args_split"] else event[
|
|
|
|
"args_split"][0]
|
2019-02-18 14:56:25 +00:00
|
|
|
event["target"].send_mode("+v", [target])
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.devoice", channel_only=True)
|
2016-05-17 13:51:47 +00:00
|
|
|
def devoice(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Remove voice from a user in the current channel
|
|
|
|
:usage: [nickname]
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: voice
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2016-07-05 11:17:22 +00:00
|
|
|
target = event["user"].nickname if not event["args_split"] else event[
|
|
|
|
"args_split"][0]
|
2019-02-18 14:56:25 +00:00
|
|
|
event["target"].send_mode("-v", [target])
|
2017-12-26 11:50:18 +00:00
|
|
|
|
2018-10-03 16:01:10 +00:00
|
|
|
@utils.hook("received.command.topic", min_args=1, channel_only=True,
|
|
|
|
remove_empty=False)
|
2018-09-06 16:25:38 +00:00
|
|
|
def topic(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Set the topic in the current channel
|
|
|
|
:usage: <topic>
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: topic
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-06 16:25:38 +00:00
|
|
|
event["target"].send_topic(event["args"])
|
2018-10-03 16:01:10 +00:00
|
|
|
@utils.hook("received.command.tappend", min_args=1, channel_only=True,
|
|
|
|
remove_empty=False)
|
2018-09-06 16:25:38 +00:00
|
|
|
def tappend(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Append to the topic in the current channel
|
|
|
|
:usage: <topic>
|
|
|
|
:require_mode: o
|
2019-01-29 00:08:21 +00:00
|
|
|
:require_access: topic
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-06 16:25:38 +00:00
|
|
|
event["target"].send_topic(event["target"].topic + event["args"])
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.message.channel")
|
2017-12-26 11:50:18 +00:00
|
|
|
def highlight_spam(self, event):
|
2018-08-06 13:27:49 +00:00
|
|
|
if event["channel"].get_setting("highlight-spam-protection", False):
|
|
|
|
nicknames = list(map(lambda user: user.nickname,
|
|
|
|
event["channel"].users)) + [event["server"].nickname]
|
|
|
|
|
2018-08-30 10:14:19 +00:00
|
|
|
highlights = set(nicknames) & set(event["message_split"])
|
|
|
|
if len(highlights) > 1 and len(highlights) >= event["channel"
|
|
|
|
].get_setting("highlight-spam-threshold", 10):
|
2018-08-06 13:27:49 +00:00
|
|
|
has_mode = event["channel"].mode_or_above(event["user"], "v")
|
|
|
|
should_ban = event["channel"].get_setting("highlight-spam-ban",
|
|
|
|
False)
|
|
|
|
if not has_mode:
|
|
|
|
if should_ban:
|
|
|
|
event["channel"].send_ban("*!%s@%s" % (
|
|
|
|
event["user"].username, event["user"].hostname))
|
|
|
|
event["channel"].send_kick(event["user"].nickname,
|
|
|
|
"highlight spam detected")
|
2018-10-02 13:55:12 +00:00
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.leave", channel_only=True)
|
2018-10-02 13:55:12 +00:00
|
|
|
def leave(self, event):
|
|
|
|
"""
|
|
|
|
:help: Part me from the current channel
|
|
|
|
:require_mode: o
|
|
|
|
"""
|
|
|
|
event["target"].send_part()
|
2019-06-27 19:38:39 +00:00
|
|
|
|
2019-06-27 19:52:32 +00:00
|
|
|
def _mute_method(self, server, user):
|
2019-06-27 19:38:39 +00:00
|
|
|
mask = "*!*@%s" % user.hostname
|
2019-06-27 19:52:32 +00:00
|
|
|
mute_method = server.get_setting("mute-method", "qmode").lower()
|
2019-06-27 19:38:39 +00:00
|
|
|
|
2019-06-27 19:52:32 +00:00
|
|
|
if mute_method == "qmode":
|
2019-06-27 19:38:39 +00:00
|
|
|
return "q", mask
|
2019-06-27 19:52:32 +00:00
|
|
|
elif mute_method == "insp":
|
2019-06-27 19:38:39 +00:00
|
|
|
return "b", "m:%s" % mask
|
2019-06-27 19:52:32 +00:00
|
|
|
elif mute_method == "unreal":
|
2019-06-27 19:38:39 +00:00
|
|
|
return "b", "~q:%s" % mask
|
2019-06-27 19:52:32 +00:00
|
|
|
raise ValueError("Unknown mute-method '%s'" % mute_method)
|
2019-06-27 19:38:39 +00:00
|
|
|
|
2019-06-27 19:52:32 +00:00
|
|
|
@utils.hook("received.command.mute", usage="<nickname> [duration]")
|
|
|
|
@utils.hook("received.command.unmute", usage="<nickname>")
|
2019-06-27 19:38:39 +00:00
|
|
|
@utils.kwarg("min_args", 1)
|
2019-06-27 20:09:26 +00:00
|
|
|
@utils.kwarg("channel_only", True)
|
|
|
|
@utils.kwarg("require_mode", "o")
|
|
|
|
@utils.kwarg("require_access", "mute")
|
2019-06-27 19:52:32 +00:00
|
|
|
@utils.kwarg("help", "Mute a given user")
|
2019-06-27 19:38:39 +00:00
|
|
|
@utils.kwarg("usage", "<nickname>")
|
2019-06-27 19:52:32 +00:00
|
|
|
def _mute(self, event):
|
|
|
|
add = event.name == "received.command.mute"
|
2019-06-27 19:38:39 +00:00
|
|
|
|
|
|
|
target_name = event["args_split"][0]
|
|
|
|
if not event["server"].has_user(target_name):
|
|
|
|
raise utils.EventError("No such user")
|
|
|
|
|
|
|
|
target_user = event["server"].get_user(target_name)
|
|
|
|
if not event["target"].has_user(target_user):
|
|
|
|
raise utils.EventError("No such user")
|
|
|
|
|
2019-06-27 19:52:32 +00:00
|
|
|
mode, mask = self._mute_method(event["server"], target_user)
|
|
|
|
|
|
|
|
if add and len(event["args_split"]) > 1:
|
|
|
|
duration = utils.from_pretty_time(event["args_split"][1])
|
|
|
|
if duration == None:
|
|
|
|
raise utils.EventError("Invalid duration")
|
|
|
|
|
|
|
|
self.timers.add_persistent("unmute", duration,
|
|
|
|
server_id=event["server"].id, channel_name=event["target"].name,
|
|
|
|
mode=mode, mask=mask)
|
|
|
|
|
2019-06-27 19:38:39 +00:00
|
|
|
mode_modifier = "+" if add else "-"
|
|
|
|
event["target"].send_mode("%s%s" % (mode_modifier, mode), [mask])
|
2019-06-27 19:52:32 +00:00
|
|
|
|
|
|
|
@utils.hook("timer.unmute")
|
|
|
|
def _timer_unmute(self, event):
|
|
|
|
server = self.bot.get_server_by_id(event["server_id"])
|
|
|
|
if server and event["channel_name"] in server.channels:
|
|
|
|
channel = server.channels.get(event["channel_name"])
|
|
|
|
channel.send_mode("-%s" % event["mode"], [event["mask"]])
|