2 from common
import resize
3 from connection
import hal
, irc
5 from globals import commands
, private
, nick
6 from basic_commands
import reply
10 def panic(who
, where
, args
):
11 "$panic: Engages panic mode in the channel. Hal will set mode +mi, clear all voices, and disable autovoice. The inverse is $unpanic."
13 reply(who
, where
, "Command not available in private, send it in a channel.")
15 hal
.connection
.mode(where
, "+mi")
16 hal
.connection
.privmsg("ChanServ", "ACCESS %s ADD %s 100" % (where
, nick
))
17 hal
.connection
.privmsg("ChanServ", "CLEAR %s VOICES" % where
)
18 hal
.connection
.privmsg("ChanServ", "ACCESS %s ADD %s 50" % (where
, nick
))
19 hal
.connection
.privmsg("ChanServ", "LEVELS %s SET AUTOVOICE 30" % where
)
20 commands
['panic'] = (perms
.op
, panic
)
22 def unpanic(who
, where
, args
):
23 "$unpanic: Disables $panic mode in the channel. Hall will set mode -i, voice everyone, and re-engage autovoice. Note that he leaves +m, since everyone is autovoiced anyway."
25 reply(who
, where
, "Command not available in private, send it in a channel.")
27 hal
.connection
.mode(where
, "-i")
28 hal
.connection
.privmsg("ChanServ", "LEVELS %s SET AUTOVOICE 0" % where
)
29 if where
in hal
.channels
:
32 for user
in hal
.channels
[where
].userdict
:
33 if len(buffer) < buffer_size
:
36 hal
.connection
.mode(where
, "+%s %s" % (("v" * buffer_size
),
40 hal
.connection
.mode(where
, "+%s %s" % (("v" * len(buffer)),
42 commands
['unpanic'] = (perms
.op
, unpanic
)
44 def kickban(who
, where
, args
):
45 """$kickban <user> <reason>: Kicks and bans a user from the channel. The ban is for *!*@<user's host>. Note that <user> is case-sensitive."""
47 reply(who
, where
, "Channel-only command.")
49 user
, reason
= resize(args
.split(" ", 1), 2)
50 whois
.userhost_callbacks
[user
] = (do_kickban
, (who
, where
, reason
))
51 hal
.connection
.userhost([user
])
52 commands
['kickban'] = (perms
.op
, kickban
)
54 def do_kickban(nm
, who
, where
, reason
):
55 hal
.connection
.mode(where
, "+b *!*@%s" % irclib
.nm_to_h(nm
))
56 hal
.connection
.kick(where
, irclib
.nm_to_n(nm
), "%s (%s)" % (reason
, who
))
58 def server_ban(who
, where
, args
):
59 """$server-ban <user> <reason>: Kicks and bans a user from the server. The ban is for *@<user's host>. Note that <user> is case-sensitive."""
60 user
, reason
= resize(args
.split(" ", 1), 2)
61 whois
.userhost_callbacks
[user
] = (do_server_ban
, (who
, where
, reason
))
62 hal
.connection
.userhost([user
])
63 commands
['server-ban'] = (perms
.ircop
, server_ban
)
65 def do_server_ban(nm
, who
, where
, reason
):
66 hal
.connection
.privmsg("OperServ", "AKILL ADD +0 *@%s %s (%s)" %
67 (irclib
.nm_to_h(nm
), reason
, who
))
68 hal
.connection
.send_raw("KILL %s %s (%s)" % (irclib
.nm_to_n(nm
), reason
, who
))
70 def kill_channel(who
, where
, args
):
71 """$kill-channel <reason>: When sent, and whenever anyone joins the channel after, Hal will run /msg OperServ AKILLCHAN KILL +0 <channel> <reason>, causing all non-oper users on the channel to be kicked off the server and permabanned."""
74 reply(who
, where
, "Channel-only command.")
76 reply(who
, where
, "Usage: $kill-channel <reason>")
78 globals.kill_channels
[where
] = reason
79 do_kill_channel(where
)
80 reply(who
, where
, "Done.")
81 commands
['kill-channel'] = (perms
.ircop
, kill_channel
)
83 def unkill_channel(who
, where
, args
):
85 reply(who
, where
, "Channel-only command.")
87 if where
in globals.kill_channels
:
88 del globals.kill_channels
[where
]
89 reply(who
, where
, "Done.")
91 reply(who
, where
, "Channel was not set to autokill.")
92 commands
['unkill-channel'] = (perms
.ircop
, unkill_channel
)
94 def do_kill_channel(channel
):
95 reason
= globals.kill_channels
[channel
]
96 hal
.connection
.privmsg("OperServ", "AKILLCHAN KILL +0 %s %s" % (channel
, reason
))
98 def got_join(conn
, event
):
99 channel
= event
.target()
100 if channel
in globals.kill_channels
:
101 do_kill_channel(channel
)
102 irc
.add_global_handler("join", got_join
)