diff options
| author | jason | 2006-08-08 02:12:09 +0000 |
|---|---|---|
| committer | jason | 2006-08-08 02:12:09 +0000 |
| commit | 52db8e8ff348f8e9c51ed894015e36458c7c040c (patch) | |
| tree | e97e14190c53f70b5204bbe1fe8543457aadca63 /warmachine.py | |
| parent | a0b8a3a265547b5f61114d971d2a9c30dfcda74b (diff) | |
| download | warmachine-52db8e8ff348f8e9c51ed894015e36458c7c040c.tar.gz warmachine-52db8e8ff348f8e9c51ed894015e36458c7c040c.zip | |
Added irc command parsing in wmd/parser.py
git-svn-id: svn://svn.zzq.org/warmachine/trunk@4 3ede8657-8418-0410-873f-eb3fb5a66eab
Diffstat (limited to 'warmachine.py')
| -rw-r--r-- | warmachine.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/warmachine.py b/warmachine.py index 0a358fc..769e7b6 100644 --- a/warmachine.py +++ b/warmachine.py | |||
| @@ -78,7 +78,17 @@ class irc: | |||
| 78 | """ | 78 | """ |
| 79 | while True: | 79 | while True: |
| 80 | data = self.irc.recv(4096) | 80 | data = self.irc.recv(4096) |
| 81 | #obj_data = parser.ircparse(data) | 81 | |
| 82 | if data == '': | ||
| 83 | continue | ||
| 84 | |||
| 85 | # Buffering for MOTD. | ||
| 86 | if data[-1] != '\n': | ||
| 87 | data = data + self.irc.recv(4096) | ||
| 88 | |||
| 89 | for line in data.split('\r\n'): | ||
| 90 | obj_data = parser.ircparse(line) | ||
| 91 | #pass to action handlers here... | ||
| 82 | 92 | ||
| 83 | # Passive Actions | 93 | # Passive Actions |
| 84 | try: | 94 | try: |
| @@ -97,14 +107,15 @@ class irc: | |||
| 97 | break | 107 | break |
| 98 | else: | 108 | else: |
| 99 | input = data.split() | 109 | input = data.split() |
| 100 | self.send('PRIVMSG ' + input[2] + ' :' + curuser + ': stop bothering me jerk.') | 110 | self.send('PRIVMSG ' + input[2] + ' :' + curuser + |
| 111 | ': stop bothering me jerk.') | ||
| 101 | except Exception,e: | 112 | except Exception,e: |
| 102 | print "Action failed" | 113 | print "Action failed" |
| 103 | print e | 114 | print e |
| 104 | 115 | ||
| 105 | 116 | ||
| 106 | if __name__ == '__main__': | 117 | if __name__ == '__main__': |
| 107 | i = irc('irc.efnet.org', 'warmachine', 'omgident') | 118 | i = irc('localhost', 'warmachine', 'omgident') |
| 108 | i.connect() | 119 | i.connect() |
| 109 | i.join('#zzq') | 120 | i.join('#zzq') |
| 110 | i.MainLoop() | 121 | i.MainLoop() |