Allow the user to configure the port in the config, and other fixes.
parent
286d4a8497
commit
986953131d
|
@ -34,7 +34,7 @@ def run_phenny(config):
|
||||||
|
|
||||||
def connect(config):
|
def connect(config):
|
||||||
p = bot.Phenny(config)
|
p = bot.Phenny(config)
|
||||||
p.run(config.host)
|
p.run(config.host, config.port)
|
||||||
|
|
||||||
Watcher()
|
Watcher()
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -75,7 +75,9 @@ def u(phenny, input):
|
||||||
if set(arg.upper()) - set(
|
if set(arg.upper()) - set(
|
||||||
'ABCDEFGHIJKLMNOPQRSTUVWYXYZ0123456789- .?+*{}[]\\/^$'):
|
'ABCDEFGHIJKLMNOPQRSTUVWYXYZ0123456789- .?+*{}[]\\/^$'):
|
||||||
printable = False
|
printable = False
|
||||||
else: printable = True
|
elif len(arg) > 1:
|
||||||
|
printable = True
|
||||||
|
else: printable = False
|
||||||
|
|
||||||
if printable:
|
if printable:
|
||||||
extended = False
|
extended = False
|
||||||
|
|
|
@ -113,7 +113,10 @@ def dict(phenny, input):
|
||||||
if len(results[key]) > 1:
|
if len(results[key]) > 1:
|
||||||
result += ', 2. ' + results[key][1]
|
result += ', 2. ' + results[key][1]
|
||||||
result += '; '
|
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']
|
dict.commands = ['dict']
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -16,8 +16,8 @@ def doc(phenny, input):
|
||||||
phenny.reply(phenny.doc[name][0])
|
phenny.reply(phenny.doc[name][0])
|
||||||
if phenny.doc[name][1]:
|
if phenny.doc[name][1]:
|
||||||
phenny.say('e.g. ' + phenny.doc[name][1])
|
phenny.say('e.g. ' + phenny.doc[name][1])
|
||||||
doc.rule = ('$nick', '(?i)help +([A-Za-z]+)(?:\?+)?$')
|
doc.rule = ('$nick', '(?i)(?:help|doc) +([A-Za-z]+)(?:\?+)?$')
|
||||||
doc.example = '$nickname: help tell?'
|
doc.example = '$nickname: doc tell?'
|
||||||
doc.priority = 'low'
|
doc.priority = 'low'
|
||||||
|
|
||||||
def commands(phenny, input):
|
def commands(phenny, input):
|
||||||
|
|
|
@ -19,6 +19,7 @@ def json(text):
|
||||||
if r_json.match(r_string.sub('', text)):
|
if r_json.match(r_string.sub('', text)):
|
||||||
text = r_string.sub(lambda m: 'u' + m.group(1), text)
|
text = r_string.sub(lambda m: 'u' + m.group(1), text)
|
||||||
return eval(text.strip(' \t\r\n'), env, {})
|
return eval(text.strip(' \t\r\n'), env, {})
|
||||||
|
print text
|
||||||
raise ValueError('Input must be serialised JSON.')
|
raise ValueError('Input must be serialised JSON.')
|
||||||
|
|
||||||
def search(query, n=1):
|
def search(query, n=1):
|
||||||
|
@ -55,6 +56,9 @@ def g(phenny, input):
|
||||||
uri = result(query)
|
uri = result(query)
|
||||||
if uri:
|
if uri:
|
||||||
phenny.reply(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)
|
else: phenny.reply("No results found for '%s'." % query)
|
||||||
g.commands = ['g']
|
g.commands = ['g']
|
||||||
g.priority = 'high'
|
g.priority = 'high'
|
||||||
|
|
|
@ -63,7 +63,7 @@ def translate(phrase, lang, target='en'):
|
||||||
translation = translation.replace('\n', ' ')
|
translation = translation.replace('\n', ' ')
|
||||||
while ' ' in translation:
|
while ' ' in translation:
|
||||||
translation = translation.replace(' ', ' ')
|
translation = translation.replace(' ', ' ')
|
||||||
return translation
|
return translation.lower()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def tr(phenny, input):
|
def tr(phenny, input):
|
||||||
|
|
|
@ -97,7 +97,8 @@ def wikipedia(term, last=False):
|
||||||
and not '(images and media)' in para
|
and not '(images and media)' in para
|
||||||
and not 'This article contains a' in para
|
and not 'This article contains a' in para
|
||||||
and not 'id="coordinates"' 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):
|
for i, para in enumerate(paragraphs):
|
||||||
para = para.replace('<sup>', '|')
|
para = para.replace('<sup>', '|')
|
||||||
|
|
5
phenny
5
phenny
|
@ -116,11 +116,16 @@ def main(argv=None):
|
||||||
name = os.path.basename(config_name).split('.')[0] + '_config'
|
name = os.path.basename(config_name).split('.')[0] + '_config'
|
||||||
module = imp.load_source(name, config_name)
|
module = imp.load_source(name, config_name)
|
||||||
module.filename = config_name
|
module.filename = config_name
|
||||||
|
|
||||||
if not hasattr(module, 'prefix'):
|
if not hasattr(module, 'prefix'):
|
||||||
module.prefix = r'\.'
|
module.prefix = r'\.'
|
||||||
|
|
||||||
if not hasattr(module, 'name'):
|
if not hasattr(module, 'name'):
|
||||||
module.name = 'Phenny Palmersbot, http://inamidst.com/phenny/'
|
module.name = 'Phenny Palmersbot, http://inamidst.com/phenny/'
|
||||||
|
|
||||||
|
if not hasattr(module, 'port'):
|
||||||
|
module.port = 6667
|
||||||
|
|
||||||
if module.host == 'irc.example.net':
|
if module.host == 'irc.example.net':
|
||||||
error = ('Error: you must edit the config file first!\n' +
|
error = ('Error: you must edit the config file first!\n' +
|
||||||
"You're currently using %s" % module.filename)
|
"You're currently using %s" % module.filename)
|
||||||
|
|
Loading…
Reference in New Issue