1 from __future__
import generators
7 from common
import multiunion
, ircdict_to_set
8 from safety
import safe
10 def voice_or_better(channel
):
11 from connection
import hal
12 if channel
in hal
.channels
:
13 chan
= hal
.channels
[channel
]
14 dicts
= (chan
.voiceddict
, chan
.hopdict
, chan
.operdict
, chan
.admindict
,
16 return multiunion(*[ircdict_to_set(d
) for d
in dicts
])
20 def callback(who
, info
):
21 raise ValueError, "Whois callback never got replaced."
28 self
.channel_perms
= {}
33 def got_whois(conn
, event
):
34 user
= event
.arguments()[0]
35 whois_info
[user
] = Whois()
36 got_whois
= safe(got_whois
)
39 def got_registered(conn
, event
):
40 args
= event
.arguments()
41 if len(args
) == 2 and args
[1] == "is a registered nick":
43 whois_info
[user
].registered
= True
44 got_registered
= safe(got_registered
)
47 def got_channels(conn
, event
):
48 args
= event
.arguments()
51 channels
= args
[1].split()
54 whois_info
[user
].channel_perms
[c
[1:]] = perms
.Perms
.from_symbol(c
[0])
56 whois_info
[user
].channel_perms
[c
] = perms
.present
57 got_channels
= safe(got_channels
)
60 def got_servop(conn
, event
):
61 args
= event
.arguments()
64 whois_info
[user
].ircop
= True
65 got_servop
= safe(got_servop
)
68 def got_whoend(conn
, event
):
69 who
= event
.arguments()[0]
70 callback(who
, whois_info
[who
])
72 user
= whois_info
[who
]
73 print "Who info for %s:" % who
74 print "Registered: %s" % user
.registered
75 print "IRCop: %s" % user
.ircop
76 p
= user
.channel_perms
77 perms
= "".join([("%s: %s, " % (k
, p
[k
])) for k
in p
])[:-2]
78 print "Channel info: %s" % perms
79 got_whoend
= safe(got_whoend
)
81 userhost_callbacks
= {}
84 def got_userhost(conn
, event
):
85 raw
= event
.arguments()[0]
86 nm
= raw
.strip().replace("=+", "!")
87 nick
= irclib
.nm_to_n(nm
)
88 if nick
in userhost_callbacks
:
89 func
, extra_args
= userhost_callbacks
[nick
]
91 got_userhost
= safe(got_userhost
)