summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSean B. Palmer <http://inamidst.com/sbp/>2008-04-26 15:54:35 +0100
committerSean B. Palmer <http://inamidst.com/sbp/>2008-04-26 15:54:35 +0100
commit986953131d1e399a9b277984a2234cd0c5f7656c (patch)
treebabe5d30a618c40b059421b43a9ca19b9b1beb14 /modules
parent286d4a8497621d2f3c0f1f8d66db60b11c87fad5 (diff)
downloadbot-986953131d1e399a9b277984a2234cd0c5f7656c.tar.gz
bot-986953131d1e399a9b277984a2234cd0c5f7656c.tar.bz2
bot-986953131d1e399a9b277984a2234cd0c5f7656c.zip
Allow the user to configure the port in the config, and other fixes.
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/codepoints.py4
-rwxr-xr-xmodules/dict.py5
-rwxr-xr-xmodules/info.py4
-rwxr-xr-xmodules/search.py4
-rwxr-xr-xmodules/translate.py2
-rwxr-xr-xmodules/wikipedia.py3
6 files changed, 16 insertions, 6 deletions
diff --git a/modules/codepoints.py b/modules/codepoints.py
index 797fada..9ae06b5 100755
--- a/modules/codepoints.py
+++ b/modules/codepoints.py
@@ -75,7 +75,9 @@ def u(phenny, input):
if set(arg.upper()) - set(
'ABCDEFGHIJKLMNOPQRSTUVWYXYZ0123456789- .?+*{}[]\\/^$'):
printable = False
- else: printable = True
+ elif len(arg) > 1:
+ printable = True
+ else: printable = False
if printable:
extended = False
diff --git a/modules/dict.py b/modules/dict.py
index 7ecaf0a..61fcee9 100755
--- a/modules/dict.py
+++ b/modules/dict.py
@@ -113,7 +113,10 @@ def dict(phenny, input):
if len(results[key]) > 1:
result += ', 2. ' + results[key][1]
result += '; '
- phenny.say(result.rstrip('; '))
+ result = result.rstrip('; ')
+ if result.endswith('-') and (len(result) < 30):
+ phenny.reply('Sorry, no definition found.')
+ else: phenny.say(result)
dict.commands = ['dict']
if __name__ == '__main__':
diff --git a/modules/info.py b/modules/info.py
index a5113ba..c3d13ef 100755
--- a/modules/info.py
+++ b/modules/info.py
@@ -16,8 +16,8 @@ def doc(phenny, input):
phenny.reply(phenny.doc[name][0])
if phenny.doc[name][1]:
phenny.say('e.g. ' + phenny.doc[name][1])
-doc.rule = ('$nick', '(?i)help +([A-Za-z]+)(?:\?+)?$')
-doc.example = '$nickname: help tell?'
+doc.rule = ('$nick', '(?i)(?:help|doc) +([A-Za-z]+)(?:\?+)?$')
+doc.example = '$nickname: doc tell?'
doc.priority = 'low'
def commands(phenny, input):
diff --git a/modules/search.py b/modules/search.py
index fbd6596..1c8dad6 100755
--- a/modules/search.py
+++ b/modules/search.py
@@ -19,6 +19,7 @@ def json(text):
if r_json.match(r_string.sub('', text)):
text = r_string.sub(lambda m: 'u' + m.group(1), text)
return eval(text.strip(' \t\r\n'), env, {})
+ print text
raise ValueError('Input must be serialised JSON.')
def search(query, n=1):
@@ -55,6 +56,9 @@ def g(phenny, input):
uri = result(query)
if uri:
phenny.reply(uri)
+ if not hasattr(phenny.bot, 'last_seen_uri'):
+ phenny.bot.last_seen_uri = {}
+ phenny.bot.last_seen_uri[input.sender] = uri
else: phenny.reply("No results found for '%s'." % query)
g.commands = ['g']
g.priority = 'high'
diff --git a/modules/translate.py b/modules/translate.py
index f7cf0a2..23ce7e9 100755
--- a/modules/translate.py
+++ b/modules/translate.py
@@ -63,7 +63,7 @@ def translate(phrase, lang, target='en'):
translation = translation.replace('\n', ' ')
while ' ' in translation:
translation = translation.replace(' ', ' ')
- return translation
+ return translation.lower()
return None
def tr(phenny, input):
diff --git a/modules/wikipedia.py b/modules/wikipedia.py
index ea32443..1af1c79 100755
--- a/modules/wikipedia.py
+++ b/modules/wikipedia.py
@@ -97,7 +97,8 @@ def wikipedia(term, last=False):
and not '(images and media)' in para
and not 'This article contains a' in para
and not 'id="coordinates"' in para
- and not 'class="thumb' in para]
+ and not 'class="thumb' in para
+ and not 'style="display:none"' in para]
for i, para in enumerate(paragraphs):
para = para.replace('<sup>', '|')