diff options
| author | jason | 2006-07-24 20:39:43 +0000 |
|---|---|---|
| committer | jason | 2006-07-24 20:39:43 +0000 |
| commit | c8a737e7e673db646a35819dab6aa560eea88a53 (patch) | |
| tree | 2ba03a74333ad890260dcac90b1bccf289e4f9d4 /actions | |
| parent | 862840e980954fd86a4dd675a158ec03f52e5d7f (diff) | |
| download | warmachine-c8a737e7e673db646a35819dab6aa560eea88a53.tar.gz warmachine-c8a737e7e673db646a35819dab6aa560eea88a53.zip | |
steve's initial framework
git-svn-id: svn://svn.zzq.org/warmachine/trunk@2 3ede8657-8418-0410-873f-eb3fb5a66eab
Diffstat (limited to 'actions')
| -rw-r--r-- | actions/ActionMap.py | 16 | ||||
| -rw-r--r-- | actions/__init__.py | 0 | ||||
| -rw-r--r-- | actions/coin.py | 17 | ||||
| -rw-r--r-- | actions/deop.py | 8 | ||||
| -rw-r--r-- | actions/devoice.py | 8 | ||||
| -rw-r--r-- | actions/join.py | 7 | ||||
| -rw-r--r-- | actions/kick.py | 9 | ||||
| -rw-r--r-- | actions/op.py | 8 | ||||
| -rw-r--r-- | actions/part.py | 7 | ||||
| -rw-r--r-- | actions/pythondoc.py | 22 | ||||
| -rw-r--r-- | actions/quit.py | 7 | ||||
| -rw-r--r-- | actions/say.py | 11 | ||||
| -rw-r--r-- | actions/settopic.py | 11 | ||||
| -rw-r--r-- | actions/voice.py | 8 |
14 files changed, 139 insertions, 0 deletions
diff --git a/actions/ActionMap.py b/actions/ActionMap.py new file mode 100644 index 0000000..4c8431f --- /dev/null +++ b/actions/ActionMap.py | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | import say, op, deop, quit, part, voice, devoice | ||
| 2 | import join, kick, pythondoc, settopic, coin | ||
| 3 | |||
| 4 | actions = {} | ||
| 5 | actions['say'] = say.say() | ||
| 6 | actions['op'] = op.op() | ||
| 7 | actions['deop'] = deop.deop() | ||
| 8 | actions['quit'] = quit.quit() | ||
| 9 | actions['part'] = part.part() | ||
| 10 | actions['voice'] = voice.voice() | ||
| 11 | actions['devoice'] = devoice.devoice() | ||
| 12 | actions['kick'] = kick.kick() | ||
| 13 | actions['join'] = join.join() | ||
| 14 | actions['pythondoc'] = pythondoc.pythondoc() | ||
| 15 | actions['settopic'] = settopic.settopic() | ||
| 16 | actions['coin'] = coin.coin() | ||
diff --git a/actions/__init__.py b/actions/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/actions/__init__.py | |||
diff --git a/actions/coin.py b/actions/coin.py new file mode 100644 index 0000000..05dfbda --- /dev/null +++ b/actions/coin.py | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | import random | ||
| 2 | |||
| 3 | class coin: | ||
| 4 | |||
| 5 | def __init__(self): | ||
| 6 | self = [] | ||
| 7 | |||
| 8 | def getAction(self, data): | ||
| 9 | ret = int(random.random()*10) | ||
| 10 | print ret | ||
| 11 | thecoin = 'The coin lands on it\'s SIDE!!!' | ||
| 12 | if ret >= 6: | ||
| 13 | thecoin = "The coin lands on HEAD." | ||
| 14 | else: | ||
| 15 | thecoin = "The coin lands on TAILS." | ||
| 16 | input = data.split(' ') | ||
| 17 | return 'PRIVMSG ' + input[4] + ' :' + thecoin | ||
diff --git a/actions/deop.py b/actions/deop.py new file mode 100644 index 0000000..d9c61eb --- /dev/null +++ b/actions/deop.py | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | class deop: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | input = data.split(' ') | ||
| 8 | return 'MODE ' + input[5] + ' -o ' + input[6] | ||
diff --git a/actions/devoice.py b/actions/devoice.py new file mode 100644 index 0000000..9539634 --- /dev/null +++ b/actions/devoice.py | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | class devoice: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | input = data.split(' ') | ||
| 8 | return 'MODE ' + input[5] + ' -v ' + input[6] | ||
diff --git a/actions/join.py b/actions/join.py new file mode 100644 index 0000000..7a36947 --- /dev/null +++ b/actions/join.py | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | class join: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | return 'JOIN ' + data[data.index('join')+5:] | ||
diff --git a/actions/kick.py b/actions/kick.py new file mode 100644 index 0000000..86416fa --- /dev/null +++ b/actions/kick.py | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | class kick: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | input = data.split(' ') | ||
| 8 | return 'KICK ' + input[5] + ' ' + input[6] | ||
| 9 | |||
diff --git a/actions/op.py b/actions/op.py new file mode 100644 index 0000000..60102c4 --- /dev/null +++ b/actions/op.py | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | class op: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | input = data.split(' ') | ||
| 8 | return 'MODE ' + input[5] + ' +o ' + input[6] | ||
diff --git a/actions/part.py b/actions/part.py new file mode 100644 index 0000000..f55e63f --- /dev/null +++ b/actions/part.py | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | class part: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | return 'PART ' + data[data.index('part')+5:] | ||
diff --git a/actions/pythondoc.py b/actions/pythondoc.py new file mode 100644 index 0000000..e420723 --- /dev/null +++ b/actions/pythondoc.py | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | import os | ||
| 2 | |||
| 3 | class pythondoc: | ||
| 4 | |||
| 5 | def __init__(self): | ||
| 6 | self = [] | ||
| 7 | |||
| 8 | def getAction(self, data): | ||
| 9 | try: | ||
| 10 | input = data.split(' ') | ||
| 11 | module = input[5].replace(' ', '') | ||
| 12 | try: | ||
| 13 | module2 = input[6][0:-2] | ||
| 14 | execstring = "python -c \"from " + module + " import " + module2 + "\nprint " + module2 + ".__doc__\n\" > /tmp/wmpycmd" | ||
| 15 | except: | ||
| 16 | module = input[5][0:-2] | ||
| 17 | execstring = "python -c \"import " + module + "\nprint " + module + ".__doc__\n\" > /tmp/wmpycmd" | ||
| 18 | os.system(execstring) | ||
| 19 | doc = file('/tmp/wmpycmd').read().replace("\n", " ") | ||
| 20 | except: | ||
| 21 | doc = "I don't know nuthn about that." | ||
| 22 | return 'PRIVMSG ' + input[2] + ' :' + doc | ||
diff --git a/actions/quit.py b/actions/quit.py new file mode 100644 index 0000000..c945f5d --- /dev/null +++ b/actions/quit.py | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | class quit: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | return 'QUIT\r\n' | ||
diff --git a/actions/say.py b/actions/say.py new file mode 100644 index 0000000..7c7273f --- /dev/null +++ b/actions/say.py | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | class say: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | input = data.split(' ') | ||
| 8 | words = "" | ||
| 9 | for word in input[6:]: | ||
| 10 | words += ' ' + word | ||
| 11 | return 'PRIVMSG ' + input[5] + ' :' + words[1:] | ||
diff --git a/actions/settopic.py b/actions/settopic.py new file mode 100644 index 0000000..8fa574a --- /dev/null +++ b/actions/settopic.py | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | class settopic: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | input = data.split(' ') | ||
| 8 | words = "" | ||
| 9 | for word in input[6:]: | ||
| 10 | words += ' ' + word | ||
| 11 | return 'TOPIC ' + input[5] + ' :' + words[1:] | ||
diff --git a/actions/voice.py b/actions/voice.py new file mode 100644 index 0000000..fe42d05 --- /dev/null +++ b/actions/voice.py | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | class voice: | ||
| 2 | |||
| 3 | def __init__(self): | ||
| 4 | self = [] | ||
| 5 | |||
| 6 | def getAction(self, data): | ||
| 7 | input = data.split(' ') | ||
| 8 | return 'MODE ' + input[5] + ' +v ' + input[6] | ||