.banheall also more hacking in trigger.py
This commit is contained in:
parent
808c46e1eb
commit
7f819740a8
|
@ -1,10 +1,6 @@
|
||||||
# coding=utf-8
|
#!/usr/bin/env python3
|
||||||
# Copyright 2010-2011, Michael Yanovich, Alek Rollyson, and Elsie Powell
|
|
||||||
# Copyright © 2012, Elad Alfassa <elad@fedoraproject.org>
|
|
||||||
# Licensed under the Eiffel Forum License 2.
|
|
||||||
from __future__ import unicode_literals, absolute_import, print_function, division
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import formatting
|
import formatting
|
||||||
from module import commands, priority, OP, HALFOP, require_privilege, require_chanmsg
|
from module import commands, priority, OP, HALFOP, require_privilege, require_chanmsg
|
||||||
from tools import Identifier
|
from tools import Identifier
|
||||||
|
|
|
@ -6,16 +6,17 @@ ban he
|
||||||
"""
|
"""
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import module
|
from module import commands, example
|
||||||
import modules.adminchannel
|
import modules.adminchannel
|
||||||
|
|
||||||
@module.commands('banhe')
|
@commands('banhe')
|
||||||
@module.example('.banhe assfaggot 30m')
|
@example('.banhe assfaggot 30m')
|
||||||
def banhe(bot, trigger):
|
def banhe(bot, trigger):
|
||||||
"""
|
"""
|
||||||
Bans he for a set period of time. Admins may set the period of time,
|
Bans he for a set period of time. Admins may set the period of time,
|
||||||
non-admins only get 20 second bans.
|
non-admins only get 20 second bans.
|
||||||
"""
|
"""
|
||||||
|
print(trigger.group())
|
||||||
banhee, period = trigger.group(3), trigger.group(4)
|
banhee, period = trigger.group(3), trigger.group(4)
|
||||||
trigger.set_nick(bot.nick)
|
trigger.set_nick(bot.nick)
|
||||||
|
|
||||||
|
@ -37,5 +38,40 @@ def banhe(bot, trigger):
|
||||||
bot.say(f"Banned \x0304{banhee}\x03 for \x0309{str(period)}\x03 seconds.")
|
bot.say(f"Banned \x0304{banhee}\x03 for \x0309{str(period)}\x03 seconds.")
|
||||||
time.sleep(period)
|
time.sleep(period)
|
||||||
modules.adminchannel.unban(bot, trigger)
|
modules.adminchannel.unban(bot, trigger)
|
||||||
bot.say("Unbanned \x0304" + banhee + "\x03")
|
bot.say(f"Unbanned \x0304{banhee}\x03")
|
||||||
|
|
||||||
|
|
||||||
|
@commands("banheall")
|
||||||
|
@example(".banheall")
|
||||||
|
def banheall(bot, trigger):
|
||||||
|
"""
|
||||||
|
Ban them all, Johnny.
|
||||||
|
"""
|
||||||
|
if not trigger.admin:
|
||||||
|
return
|
||||||
|
period = trigger.group(2)
|
||||||
|
trigger.set_nick(bot.nick)
|
||||||
|
|
||||||
|
conv = {'s':1, 'm':60, 'h':3600, 'd':86400}
|
||||||
|
try:
|
||||||
|
period = conv[period[-1]] * int(period[:-1])
|
||||||
|
except (KeyError, ValueError, TypeError):
|
||||||
|
period = 0
|
||||||
|
|
||||||
|
for nick in bot.privileges[trigger.sender].keys():
|
||||||
|
trigger.set_group(f".banhe {nick}")
|
||||||
|
modules.adminchannel.ban(bot, trigger)
|
||||||
|
|
||||||
|
if period > 2592000:
|
||||||
|
bot.reply("It's too big, Onii-chan.")
|
||||||
|
if not period or period > 2592000:
|
||||||
|
return bot.say("Banned \x0304them all\x03 for \x0309∞\x03 seconds.")
|
||||||
|
|
||||||
|
bot.say(f"Banned \x0304them all\x03 for \x0309{str(period)}\x03 seconds.")
|
||||||
|
time.sleep(period)
|
||||||
|
|
||||||
|
for nick in bot.privileges[trigger.sender].keys():
|
||||||
|
trigger.set_group(f".banhe {nick}")
|
||||||
|
modules.adminchannel.unban(bot, trigger)
|
||||||
|
|
||||||
|
bot.say("Unbanned \x0304them all\x03")
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#! /usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
"""
|
||||||
Pings everyone in the channel.
|
Pings everyone in the channel.
|
||||||
"""
|
"""
|
||||||
|
@ -12,6 +11,6 @@ def pingAll(bot, trigger):
|
||||||
attention, or just annoy them.
|
attention, or just annoy them.
|
||||||
"""
|
"""
|
||||||
msg = ""
|
msg = ""
|
||||||
for name, priv in bot.privileges[trigger.sender].items():
|
for name in bot.privileges[trigger.sender].keys():
|
||||||
msg += name + ' '
|
msg += name + ' '
|
||||||
bot.say(msg.strip())
|
bot.say(msg.strip())
|
||||||
|
|
|
@ -24,7 +24,7 @@ def filename(self):
|
||||||
def load_database(name):
|
def load_database(name):
|
||||||
data = {}
|
data = {}
|
||||||
if os.path.isfile(name):
|
if os.path.isfile(name):
|
||||||
f = codecs.open(name, 'r', encoding='utf-8')
|
f = codecs.open(name, 'r')
|
||||||
for line in f:
|
for line in f:
|
||||||
unixtime, channel, nick, message = line.split('\t')
|
unixtime, channel, nick, message = line.split('\t')
|
||||||
message = message.rstrip('\n')
|
message = message.rstrip('\n')
|
||||||
|
|
|
@ -186,4 +186,9 @@ class Trigger(str):
|
||||||
def set_nick(self, new_nick):
|
def set_nick(self, new_nick):
|
||||||
"""Sets the trigger's nick to something new."""
|
"""Sets the trigger's nick to something new."""
|
||||||
self._pretrigger.nick = new_nick
|
self._pretrigger.nick = new_nick
|
||||||
self._nick = self._pretrigger.nick
|
self._nick = self._pretrigger.nick
|
||||||
|
|
||||||
|
def set_group(self, new_group):
|
||||||
|
"""Sets the trigger's group to something new."""
|
||||||
|
self._match = re.match("\..+", new_group)
|
||||||
|
self._group = self._match.group()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user