11from cloudbot import hook
22
33
4- def check_for_chan_mode (char , conn ):
4+ def check_for_chan_mode (char , conn , notice , mode_warn ):
55 serv_info = conn .memory ["server_info" ]
66 modes = serv_info .get ("channel_modes" , "" )
7- return bool (char in modes )
7+ status = serv_info .get ("statuses" , [])
8+ if char in modes or char in status :
9+ return True
810
11+ if mode_warn :
12+ notice ("Mode character '{}' does not seem to exist on this network." .format (char ))
913
10- def mode_cmd (mode , text , text_inp , chan , conn , notice , nick , admin_log ):
14+ return False
15+
16+
17+ def mode_cmd (mode , text , text_inp , chan , conn , notice , nick , admin_log , mode_warn = True ):
1118 """ generic mode setting function """
12- if not check_for_chan_mode (mode [1 ], conn ):
19+ if not check_for_chan_mode (mode [1 ], conn , notice , mode_warn ):
1320 return False
1421
1522 split = text_inp .split (" " )
@@ -27,9 +34,9 @@ def mode_cmd(mode, text, text_inp, chan, conn, notice, nick, admin_log):
2734 return True
2835
2936
30- def mode_cmd_no_target (mode , text , text_inp , chan , conn , notice , nick , admin_log ):
37+ def mode_cmd_no_target (mode , text , text_inp , chan , conn , notice , nick , admin_log , mode_warn = True ):
3138 """ generic mode setting function without a target"""
32- if not check_for_chan_mode (mode [1 ], conn ):
39+ if not check_for_chan_mode (mode [1 ], conn , notice , mode_warn ):
3340 return False
3441
3542 split = text_inp .split (" " )
@@ -79,7 +86,7 @@ def unban(text, conn, chan, notice, nick, admin_log):
7986@hook .command (permissions = ["op_quiet" , "op" , "chanop" ])
8087def quiet (text , conn , chan , notice , nick , admin_log ):
8188 """[channel] <user> - quiets <user> in [channel], or in the caller's channel if no channel is specified"""
82- if mode_cmd ("+q" , "quiet" , text , chan , conn , notice , nick , admin_log ):
89+ if mode_cmd ("+q" , "quiet" , text , chan , conn , notice , nick , admin_log , False ):
8390 return
8491
8592 if not do_extban ('m' , "quiet" , text , chan , conn , notice , nick , admin_log , True ):
@@ -89,7 +96,7 @@ def quiet(text, conn, chan, notice, nick, admin_log):
8996@hook .command (permissions = ["op_quiet" , "op" , "chanop" ])
9097def unquiet (text , conn , chan , notice , nick , admin_log ):
9198 """[channel] <user> - unquiets <user> in [channel], or in the caller's channel if no channel is specified"""
92- if mode_cmd ("-q" , "unquiet" , text , chan , conn , notice , nick , admin_log ):
99+ if mode_cmd ("-q" , "unquiet" , text , chan , conn , notice , nick , admin_log , False ):
93100 return
94101
95102 if not do_extban ('m' , "unquiet" , text , chan , conn , notice , nick , admin_log , False ):
0 commit comments