diff options
| -rw-r--r-- | conf/users.py | 1 | ||||
| -rw-r--r-- | passiveactions/autoop.py | 10 | ||||
| -rw-r--r-- | warmachine.py | 19 | ||||
| -rw-r--r-- | wmd/parser.py | 10 |
4 files changed, 27 insertions, 13 deletions
diff --git a/conf/users.py b/conf/users.py index 174380c..3ef926d 100644 --- a/conf/users.py +++ b/conf/users.py | |||
| @@ -3,3 +3,4 @@ user.append('ashcrow') | |||
| 3 | user.append('beav') | 3 | user.append('beav') |
| 4 | user.append('wes') | 4 | user.append('wes') |
| 5 | user.append('com4') | 5 | user.append('com4') |
| 6 | user.append('jason_') | ||
diff --git a/passiveactions/autoop.py b/passiveactions/autoop.py index 45ae9e4..5724df5 100644 --- a/passiveactions/autoop.py +++ b/passiveactions/autoop.py | |||
| @@ -5,11 +5,13 @@ class autoop: | |||
| 5 | 5 | ||
| 6 | def getAction(self, data, users): | 6 | def getAction(self, data, users): |
| 7 | try: | 7 | try: |
| 8 | input = data.split() | 8 | if data.command == 'JOIN': |
| 9 | if 'JOIN' in input[1]: | 9 | user = data.prefix[0:data.prefix.index('!')] |
| 10 | user = data[1:data.index('!')] | ||
| 11 | if user in users: | 10 | if user in users: |
| 12 | print "autoop" | 11 | print "autoop" |
| 13 | return 'MODE ' + input[2][1:] + ' +o ' + user | 12 | |
| 13 | if data.params[0] == ':': | ||
| 14 | data.params = data.params[1:] | ||
| 15 | return 'MODE ' + data.params + ' +o ' + user | ||
| 14 | except: | 16 | except: |
| 15 | return False | 17 | return False |
diff --git a/warmachine.py b/warmachine.py index 769e7b6..ed4fcda 100644 --- a/warmachine.py +++ b/warmachine.py | |||
| @@ -89,13 +89,22 @@ 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 | print "!" + obj_data.prefix + "~" + obj_data.command + "~" + obj_data.params | ||
| 93 | try: | ||
| 94 | for key in passiveactions.keys(): | ||
| 95 | pa = passiveactions[key].getAction(obj_data, user) | ||
| 96 | if pa: | ||
| 97 | self.send(pa) | ||
| 98 | except Exception,e: | ||
| 99 | print "Action failed" | ||
| 100 | print e | ||
| 92 | 101 | ||
| 93 | # Passive Actions | 102 | # Passive Actions |
| 94 | try: | 103 | try: |
| 95 | for key in passiveactions.keys(): | 104 | # for key in passiveactions.keys(): |
| 96 | pa = passiveactions[key].getAction(data, user) | 105 | # pa = passiveactions[key].getAction(data, user) |
| 97 | if pa: | 106 | # if pa: |
| 98 | self.send(pa) | 107 | # self.send(pa) |
| 99 | # Direct Actions | 108 | # Direct Actions |
| 100 | if data.find(self.nick + ':') != -1: | 109 | if data.find(self.nick + ':') != -1: |
| 101 | curuser = data[1:data.index('!')] | 110 | curuser = data[1:data.index('!')] |
| @@ -115,7 +124,7 @@ class irc: | |||
| 115 | 124 | ||
| 116 | 125 | ||
| 117 | if __name__ == '__main__': | 126 | if __name__ == '__main__': |
| 118 | i = irc('localhost', 'warmachine', 'omgident') | 127 | i = irc('irc.servercentral.net', 'warmachine', 'omgident') |
| 119 | i.connect() | 128 | i.connect() |
| 120 | i.join('#zzq') | 129 | i.join('#zzq') |
| 121 | i.MainLoop() | 130 | i.MainLoop() |
diff --git a/wmd/parser.py b/wmd/parser.py index a413594..99173be 100644 --- a/wmd/parser.py +++ b/wmd/parser.py | |||
| @@ -28,13 +28,15 @@ class ircparse(object): | |||
| 28 | pass | 28 | pass |
| 29 | 29 | ||
| 30 | # Command comes 2nd (Or first if the prefix is missing) | 30 | # Command comes 2nd (Or first if the prefix is missing) |
| 31 | self.command = data.split(' ')[1] | 31 | if len(data.split(' ')) > 1: |
| 32 | self.command = data.split(' ')[1] | ||
| 32 | 33 | ||
| 33 | # Finally we reconstruct the parameters. We'll let the plugins figure out | 34 | # Finally we reconstruct the parameters. We'll let the plugins figure out |
| 34 | # what they mean since they could potentially be very different. | 35 | # what they mean since they could potentially be very different. |
| 35 | for param in data.split(' ')[2:]: | 36 | if len(data.split(' ')) > 2: |
| 36 | self.params += param + " " | 37 | for param in data.split(' ')[2:]: |
| 37 | self.params.strip() | 38 | self.params += param + " " |
| 39 | self.params.strip() | ||
| 38 | 40 | ||
| 39 | class configparse(object): | 41 | class configparse(object): |
| 40 | def __init__(self, filename): | 42 | def __init__(self, filename): |