summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason2006-08-09 16:26:01 +0000
committerjason2006-08-09 16:26:01 +0000
commit54f503bf5a529c9622c3b40db767f8213334a46f (patch)
treea84ee1edee967dfe75378cedb647ac443068e239
parentaf820c55f401b0ea73ea91d71f8cb5bc5f06c3f1 (diff)
downloadwarmachine-54f503bf5a529c9622c3b40db767f8213334a46f.tar.gz
warmachine-54f503bf5a529c9622c3b40db767f8213334a46f.zip
The rest of the plugins have been converted to the parser object style.
git-svn-id: svn://svn.zzq.org/warmachine/trunk@10 3ede8657-8418-0410-873f-eb3fb5a66eab
-rw-r--r--actions/coin.py4
-rw-r--r--actions/deop.py5
-rw-r--r--actions/devoice.py5
-rw-r--r--actions/join.py3
-rw-r--r--actions/kick.py5
-rw-r--r--actions/op.py5
-rw-r--r--actions/part.py3
-rw-r--r--actions/say.py14
-rw-r--r--actions/settopic.py14
-rw-r--r--actions/voice.py5
-rw-r--r--warmachine.py37
11 files changed, 51 insertions, 49 deletions
diff --git a/actions/coin.py b/actions/coin.py
index 05dfbda..36392af 100644
--- a/actions/coin.py
+++ b/actions/coin.py
@@ -13,5 +13,5 @@ class coin:
13 thecoin = "The coin lands on HEAD." 13 thecoin = "The coin lands on HEAD."
14 else: 14 else:
15 thecoin = "The coin lands on TAILS." 15 thecoin = "The coin lands on TAILS."
16 input = data.split(' ') 16 channel = data.params[0:data.params.index(' ')]
17 return 'PRIVMSG ' + input[4] + ' :' + thecoin 17 return 'PRIVMSG ' + channel + ' :' + thecoin
diff --git a/actions/deop.py b/actions/deop.py
index d9c61eb..38d54ca 100644
--- a/actions/deop.py
+++ b/actions/deop.py
@@ -4,5 +4,6 @@ class deop:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 input = data.split(' ') 7 channel = data.params[0:data.params.index(' ')]
8 return 'MODE ' + input[5] + ' -o ' + input[6] 8 user = data.params.split(' ')[3]
9 return 'MODE ' + channel + ' -o ' + user
diff --git a/actions/devoice.py b/actions/devoice.py
index 9539634..e820466 100644
--- a/actions/devoice.py
+++ b/actions/devoice.py
@@ -4,5 +4,6 @@ class devoice:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 input = data.split(' ') 7 channel = data.params[0:data.params.index(' ')]
8 return 'MODE ' + input[5] + ' -v ' + input[6] 8 user = data.params.split(' ')[3]
9 return 'MODE ' + channel + ' -v ' + user
diff --git a/actions/join.py b/actions/join.py
index 7a36947..44246be 100644
--- a/actions/join.py
+++ b/actions/join.py
@@ -4,4 +4,5 @@ class join:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 return 'JOIN ' + data[data.index('join')+5:] 7 channel = data.params.split(' ')[3]
8 return 'JOIN ' + channel
diff --git a/actions/kick.py b/actions/kick.py
index 86416fa..0725ef5 100644
--- a/actions/kick.py
+++ b/actions/kick.py
@@ -4,6 +4,7 @@ class kick:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 input = data.split(' ') 7 channel = data.params[0:data.params.index(' ')]
8 return 'KICK ' + input[5] + ' ' + input[6] 8 user = data.params.split(' ')[3]
9 return 'KICK ' + channel + ' ' + user
9 10
diff --git a/actions/op.py b/actions/op.py
index 60102c4..9c9df6c 100644
--- a/actions/op.py
+++ b/actions/op.py
@@ -4,5 +4,6 @@ class op:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 input = data.split(' ') 7 channel = data.params[0:data.params.index(' ')]
8 return 'MODE ' + input[5] + ' +o ' + input[6] 8 user = data.params.split(' ')[3]
9 return 'MODE ' + channel + ' +o ' + user
diff --git a/actions/part.py b/actions/part.py
index f55e63f..508a44a 100644
--- a/actions/part.py
+++ b/actions/part.py
@@ -4,4 +4,5 @@ class part:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 return 'PART ' + data[data.index('part')+5:] 7 channel = data.params.split(' ')[3]
8 return 'PART ' + channel
diff --git a/actions/say.py b/actions/say.py
index 7c7273f..1d2a916 100644
--- a/actions/say.py
+++ b/actions/say.py
@@ -4,8 +4,12 @@ class say:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 input = data.split(' ') 7 channel = data.params.split(' ')[3]
8 words = "" 8 words = data.params.split(' ')[4:]
9 for word in input[6:]: 9
10 words += ' ' + word 10
11 return 'PRIVMSG ' + input[5] + ' :' + words[1:] 11 say = ""
12 for word in words:
13 say += word + " "
14
15 return 'PRIVMSG ' + channel + ' :' + say
diff --git a/actions/settopic.py b/actions/settopic.py
index 8fa574a..91ecc6c 100644
--- a/actions/settopic.py
+++ b/actions/settopic.py
@@ -4,8 +4,12 @@ class settopic:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 input = data.split(' ') 7 channel = data.params.split(' ')[3]
8 words = "" 8 words = data.params.split(' ')[4:]
9 for word in input[6:]: 9
10 words += ' ' + word 10
11 return 'TOPIC ' + input[5] + ' :' + words[1:] 11 say = ""
12 for word in words:
13 say += word + " "
14
15 return 'TOPIC ' + channel + ' :' + say
diff --git a/actions/voice.py b/actions/voice.py
index fe42d05..ea72d4f 100644
--- a/actions/voice.py
+++ b/actions/voice.py
@@ -4,5 +4,6 @@ class voice:
4 self = [] 4 self = []
5 5
6 def getAction(self, data): 6 def getAction(self, data):
7 input = data.split(' ') 7 channel = data.params[0:data.params.index(' ')]
8 return 'MODE ' + input[5] + ' +v ' + input[6] 8 user = data.params.split(' ')[3]
9 return 'MODE ' + channel + ' +v ' + user
diff --git a/warmachine.py b/warmachine.py
index 426904f..c9a03eb 100644
--- a/warmachine.py
+++ b/warmachine.py
@@ -89,40 +89,27 @@ class irc:
89 for line in data.split('\r\n'): 89 for line in data.split('\r\n'):
90 obj_data = parser.ircparse(line) 90 obj_data = parser.ircparse(line)
91 #pass to action handlers here... 91 #pass to action handlers here...
92 if (obj_data.prefix == '') and (obj_data.command == '') and (obj_data.params == ''):
93 continue
94
92 print "!" + obj_data.prefix + "~" + obj_data.command + "~" + obj_data.params 95 print "!" + obj_data.prefix + "~" + obj_data.command + "~" + obj_data.params
93 try: 96 try:
94 for key in passiveactions.keys(): 97 for key in passiveactions.keys():
95 pa = passiveactions[key].getAction(obj_data, user) 98 pa = passiveactions[key].getAction(obj_data, user)
96 if pa: 99 if pa:
97 self.send(pa) 100 self.send(pa)
98 except Exception,e:
99 print "Action failed"
100 print e
101 101
102 # Passive Actions 102 if obj_data.params.find(self.nick + ':') > -1:
103 try: 103 curuser = obj_data.getUsername()
104 #for key in passiveactions.keys(): 104 if curuser not in user:
105 # pa = passiveactions[key].getAction(data, user) 105 continue
106 # if pa:
107 # self.send(pa)
108 # Direct Actions
109 if data.find(self.nick + ':') != -1:
110 curuser = data[1:data.index('!')]
111 if curuser in user:
112 input = data.split()
113 print "$$ " + input
114 for key in actions.keys(): 106 for key in actions.keys():
115 if data.find(key) != -1: 107 if obj_data.params.find(key) > -1:
116 self.send(actions[key].getAction(data)) 108 self.send(actions[key].getAction(obj_data))
117 break
118 else:
119 input = data.split()
120 self.send('PRIVMSG ' + input[2] + ' :' + curuser +
121 ': stop bothering me jerk.')
122 except Exception,e:
123 print "Action failed"
124 print e
125 109
110 except Exception,e:
111 print "Action failed"
112 print e
126 113
127if __name__ == '__main__': 114if __name__ == '__main__':
128 i = irc('irc.inter.net.il', 'warmachine', 'omgident') 115 i = irc('irc.inter.net.il', 'warmachine', 'omgident')