-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
64 lines (46 loc) · 1.73 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from irc_class import *
from botConfig import *
irc = IRC()
def main():
irc.connect()
while True:
irc.delayMsgCheck()
ircmsg = irc.get_response()
# try: print(ircmsg)
# except: dontprint = 'okay'
if (' TOPIC ' in ircmsg
or ' NOTICE ' in ircmsg
or ' PRIVMSG ' in ircmsg
):
ircMsgSplit = ircmsg.split(' ',3)
sender = ircMsgSplit[0]
sendersCmd = ircMsgSplit[1]
target = ircMsgSplit[2]
message = ircMsgSplit[3]
if message.startswith(':'): message = message[1:]
if 'NOTICE' == sendersCmd or 'PRIVMSG' == sendersCmd:
# msgType
if target.startswith('#'):
msgType = 'channel'
elif target == BotNick :
msgType = 'dm'
ShutingDown = False
try:
main()
except KeyboardInterrupt: # Kill Bot from CLI using CTRL+C / SIGINT
ShutingDown = True
irc.ircsend(f'QUIT {quitMsg}')
sys.exit()
# ":[server] PING :[message]"
# ":[server] [numeric] [message]"
# ":[Nick]!~[hostname]@[IPAddress] AWAY"
# ":[Nick]!~[hostname]@[IPAddress] PART [channel]"
# ":[Nick]!~[hostname]@[IPAddress] QUIT :[message]"
# ":[Nick]!~[hostname]@[IPAddress] JOIN :[channel]"
# ":[Nick]!~[hostname]@[IPAddress] INVITE :[channel]"
# ":[Nick]!~[hostname]@[IPAddress] TOPIC [channel] :[message]"
# ":[Nick]!~[hostname]@[IPAddress] NOTICE [channel] :[message]"
# ":[Nick]!~[hostname]@[IPAddress] PRIVMSG [channel] :[message]"
# ":[Nick]!~[hostname]@[IPAddress] KICK [channel] [user2BeKicked] :[message]"
#
# ":[Nick]!~[hostname]@[IPAddress] PRIVMSG [channel] :ACTION [message]" ** Note: \001 ctcp action