Added reminders module.

master
Sean B. Palmer 2011-02-23 21:32:37 +00:00
parent 4608c57ea8
commit 4a2b9efbe7
5 changed files with 16 additions and 32 deletions

View File

@ -78,6 +78,8 @@ def c(phenny, input):
answer = [p for p in parts if p.startswith('rhs: "')][0][6:]
if answer:
answer = answer.decode('unicode-escape')
answer = ''.join(chr(ord(c)) for c in answer)
answer = answer.decode('utf-8')
answer = answer.replace(u'\xc2\xa0', ',')
answer = answer.replace('<sup>', '^(')
answer = answer.replace('</sup>', ')')
@ -97,7 +99,7 @@ def py(phenny, input):
py.commands = ['py']
def wa(phenny, input):
query = input.group(2)
query = input.group(2).encode('utf-8')
uri = 'http://tumbolia.appspot.com/wa/'
answer = web.get(uri + web.urllib.quote(query))
if answer:

View File

@ -26,6 +26,7 @@ def head(phenny, input):
if not uri.startswith('htt'):
uri = 'http://' + uri
# uri = uri.replace('#!', '?_escaped_fragment_=')
try: info = web.head(uri)
except IOError: return phenny.say("Can't connect to %s" % uri)
@ -80,6 +81,7 @@ def f_title(self, origin, match, args):
if not ':' in uri:
uri = 'http://' + uri
uri = uri.replace('#!', '?_escaped_fragment_=')
try:
redirects = 0

View File

@ -30,9 +30,9 @@ def mappings(uri):
def service(phenny, input, command, args):
t = o.services[command]
template = t.replace('${args}', urllib.quote(args.encode('utf-8')))
template = template.replace('${nick}', urllib.quote(input.nick))
uri = template.replace('${sender}', urllib.quote(input.sender))
template = t.replace('${args}', urllib.quote(args.encode('utf-8'), ''))
template = template.replace('${nick}', urllib.quote(input.nick, ''))
uri = template.replace('${sender}', urllib.quote(input.sender, ''))
info = web.head(uri)
if isinstance(info, list):

View File

@ -82,13 +82,13 @@ def f_remind(phenny, input):
if not phenny.reminders.has_key(tellee):
phenny.reminders[tellee] = [(teller, verb, timenow, msg)]
else:
if len(phenny.reminders[tellee]) >= maximum:
warn = True
# if len(phenny.reminders[tellee]) >= maximum:
# warn = True
phenny.reminders[tellee].append((teller, verb, timenow, msg))
# @@ Stephanie's augmentation
response = "I'll pass that on when %s is around." % tellee_original
if warn: response += (" I'll have to use a pastebin, though, so " +
"your message may get lost.")
# if warn: response += (" I'll have to use a pastebin, though, so " +
# "your message may get lost.")
rand = random.random()
if rand > 0.9999: response = "yeah, yeah"
@ -138,29 +138,9 @@ def message(phenny, input):
phenny.say(line)
if reminders[maximum:]:
try:
if origin.sender in lispchannels:
chan = origin.sender
else: chan = 'None'
result = web.post('http://paste.lisp.org/submit',
{'channel': chan,
'username': phenny.nick,
'title': 'Further Messages for %s' % tellee,
'colorize': 'None',
'text': '\n'.join(reminders[maximum:]) + '\n',
'captcha': 'lisp',
'captchaid': 'bdf447484f62a3e8b23816f9acee79d9'
}
)
uris = re.findall('http://paste.lisp.org/display/\d+', result)
uri = list(reversed(uris)).pop()
if not origin.sender in lispchannels:
message = '%s: see %s for further messages' % (tellee, uri)
phenny.say(message)
except:
error = '[Sorry, some messages were elided and lost...]'
phenny.say(error)
phenny.say('Further messages sent privately')
for line in reminders[maximum:]:
phenny.msg(tellee, line)
if len(phenny.reminders.keys()) != remkeys:
dumpReminders(phenny.tell_filename, phenny.reminders) # @@ tell

View File

@ -24,7 +24,7 @@ r_redirect = re.compile(
abbrs = ['etc', 'ca', 'cf', 'Co', 'Ltd', 'Inc', 'Mt', 'Mr', 'Mrs',
'Dr', 'Ms', 'Rev', 'Fr', 'St', 'Sgt', 'pron', 'approx', 'lit',
'syn', 'transl', 'sess', 'fl', 'Op'] \
'syn', 'transl', 'sess', 'fl', 'Op', 'Dec'] \
+ list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') \
+ list('abcdefghijklmnopqrstuvwxyz')
t_sentence = r'^.{5,}?(?<!\b%s)(?:\.(?=[\[ ][A-Z0-9]|\Z)|\Z)'