-
Notifications
You must be signed in to change notification settings - Fork 1
/
general.py
89 lines (68 loc) · 2.65 KB
/
general.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import sys, os
#Update schema
__url__ = "https://raw.githubusercontent.com/KittyHawkIrc/modules/production/" + __name__ + ".py"
__version__ = 1.0
def declare():
return {"restart": "privmsg", "join": "privmsg", "leave": "privmsg", "nick": "privmsg", "kick": "privmsg", "ban": "privmsg", "unban": "privmsg", "msg": "privmsg", "topic": "privmsg"}
def callback(self):
channel = self.channel
command = self.command
user = self.user
msg = self.message
type = self.type
isop = self.isop
if isop == False:
username = user.split('!')[0]
self.msg(username, 'I only accept commands from bot operators')
return
if channel.startswith('#') == False:
username = user.split('!',1)[0]
if command == 'restart':
args = sys.argv[:]
args.insert(0, sys.executable)
#os.chdir(_startup_cwd)
os.execv(sys.executable, args)
elif command == 'join':
self.join(msg.split(' ')[1])
u = user.split('!',1)[0]
self.msg(u, 'joined ' + msg.split(' ')[1])
elif command == 'leave':
self.leave(msg.split(' ')[1])
u = user.split('!',1)[0]
self.msg(u, 'left ' + msg.split(' ')[1])
elif command == 'nick':
self.setNick(msg.split(' ')[1])
u = user.split('!',1)[0]
self.msg(u, 'now known as ' + msg.split(' ')[1])
elif command == 'kick':
channel = msg.split(' ')[1]
user = msg.split(' ')[2]
try:
reason = msg.split(' ', 3)[3]
self.kick(channel, user, reason=reason)
except:
self.kick(channel, user)
u = user.split('!',1)[0]
self.msg(u, 'kicked ' + user)
elif command == 'ban':
channel = msg.split(' ')[1]
hostmask = msg.split(' ')[2]
self.mode(channel ,True, 'b', mask=hostmask)
u = user.split('!',1)[0]
self.msg(u, 'banned ' + hostmask)
elif command == 'msg':
channel = msg.split(' ')[1]
msg = msg.split(' ', 2)[2]
self.msg(channel, msg)
elif command == 'topic':
channel = msg.split(' ')[1]
topic = msg.split(' ', 2)[2]
self.topic(channel, topic=topic)
u = user.split('!',1)[0]
self.msg(u, 'topic set to ' + topic)
elif command == 'unban':
channel = msg.split(' ')[1]
hostmask = msg.split(' ')[2]
self.mode(channel ,False , 'b', mask=hostmask)
u = user.split('!',1)[0]
self.msg(u, 'unbanned ' + hostmask)