4 from globals import DEBUG
, nick
, server
, port
, autojoin_channels
5 from safety
import safe
8 hal
= ircbot
.SingleServerIRCBot([(server
, port
)], nick
, "Halbot")
9 hal
.connect(server
, port
, nick
)
11 hal
.connection
.privmsg("NickServ", "identify Orqv)>y!")
12 for channel
in autojoin_channels
:
13 hal
.connection
.join(channel
)
18 def got_invite(conn
, event
):
19 who
= irclib
.nm_to_n(event
.source())
20 where
= event
.arguments()[0]
21 got_command(who
, where
, "do join")
22 got_invite
= safe(got_invite
)
23 irc
.add_global_handler("invite", got_invite
)
26 def got_msg(conn
, event
):
28 if irclib
.mask_matches(event
.source(), user
):
29 if my_users
[user
] == Perms
.ban
:
31 msg
= event
.arguments()[0]
32 who
= irclib
.nm_to_n(event
.source())
33 (command
, args
) = resize(msg
.split(" ", 1),2)
34 if command
and command
[0] == "$":
37 if event
.eventtype() == 'privmsg':
40 where
= event
.target()
41 if msg
.count("http://"):
42 got_command(who
, where
, "title implicit", html
.extract_url(msg
))
44 if nick_re
.match(msg
):
45 (me
, command
, args
) = resize(msg
.split(" ", 2),3)
46 if command
in commands
:
48 elif is_re
.search(msg
):
50 args
= is_re
.split(msg
.split(" ", 1)[1], 1)
52 command
= "factoid implicit"
53 args
= msg
.split(" ", 1)[1]
55 if command
in commands
and commands
[command
][0] <= Perms
.voice
:
57 elif is_re
.search(msg
):
59 args
= is_re
.split(msg
, 1)
61 command
= "factoid implicit"
63 got_command(who
, where
, command
, args
)
64 got_msg
= safe(got_msg
)
65 irc
.add_global_handler("privmsg", got_msg
)
66 irc
.add_global_handler("pubmsg", got_msg
)
70 cmd
= sys
.stdin
.readline().strip()
72 hal
.connection
.send_raw(cmd
)
75 irc
.process_forever(None)
77 thread
.start_new_thread(debug_console
, ())
78 thread
.start_new_thread(run_reminders
, ())