78 lines
1.9 KiB
Python
Executable File
78 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
ban he
|
|
ban he
|
|
ban he
|
|
"""
|
|
import time
|
|
|
|
from module import commands, example
|
|
import modules.adminchannel
|
|
|
|
@commands('banhe')
|
|
@example('.banhe assfaggot 30m')
|
|
def banhe(bot, trigger):
|
|
"""
|
|
Bans he for a set period of time. Admins may set the period of time,
|
|
non-admins only get 20 second bans.
|
|
"""
|
|
print(trigger.group())
|
|
banhee, period = trigger.group(3), trigger.group(4)
|
|
trigger.set_nick(bot.nick)
|
|
|
|
if not trigger.admin:
|
|
period = 20
|
|
else:
|
|
conv = {'s':1, 'm':60, 'h':3600, 'd':86400}
|
|
try:
|
|
period = conv[period[-1]] * int(period[:-1])
|
|
except (KeyError, ValueError, TypeError):
|
|
period = 0
|
|
|
|
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(f"Banned \x0304{banhee}\x03 for \x0309∞\x03 seconds.")
|
|
|
|
bot.say(f"Banned \x0304{banhee}\x03 for \x0309{str(period)}\x03 seconds.")
|
|
time.sleep(period)
|
|
modules.adminchannel.unban(bot, trigger)
|
|
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")
|