1 from __future__
import generators
5 from common
import multiunion
, ircdict_to_set
6 from safety
import safe
8 def voice_or_better(channel
):
9 from connection
import hal
10 if channel
in hal
.channels
:
11 chan
= hal
.channels
[channel
]
12 dicts
= (chan
.voiceddict
, chan
.hopdict
, chan
.operdict
, chan
.admindict
,
14 return multiunion(*[ircdict_to_set(d
) for d
in dicts
])
18 def callback(who
, info
):
19 raise ValueError, "Whois callback never got replaced."
26 self
.channel_perms
= {}
31 def got_whois(conn
, event
):
32 user
= event
.arguments()[0]
33 whois_info
[user
] = Whois()
34 got_whois
= safe(got_whois
)
37 def got_registered(conn
, event
):
38 args
= event
.arguments()
39 if len(args
) == 2 and args
[1] == "is a registered nick":
41 whois_info
[user
].registered
= True
42 got_registered
= safe(got_registered
)
45 def got_channels(conn
, event
):
46 args
= event
.arguments()
49 channels
= args
[1].split()
52 whois_info
[user
].channel_perms
[c
[1:]] = perms
.Perms
.from_symbol(c
[0])
54 whois_info
[user
].channel_perms
[c
] = perms
.present
55 got_channels
= safe(got_channels
)
58 def got_servop(conn
, event
):
59 args
= event
.arguments()
62 whois_info
[user
].ircop
= True
63 got_servop
= safe(got_servop
)
66 def got_whoend(conn
, event
):
67 who
= event
.arguments()[0]
68 callback(who
, whois_info
[who
])
70 user
= whois_info
[who
]
71 print "Who info for %s:" % who
72 print "Registered: %s" % user
.registered
73 print "IRCop: %s" % user
.ircop
74 p
= user
.channel_perms
75 perms
= "".join([("%s: %s, " % (k
, p
[k
])) for k
in p
])[:-2]
76 print "Channel info: %s" % perms
77 got_whoend
= safe(got_whoend
)