Patched remember append bug
This commit is contained in:
parent
d5e192de10
commit
5c29e27b43
|
@ -35,12 +35,17 @@ def remember(inp, nick='', chan='', db=None):
|
||||||
|
|
||||||
data = get_memory(db, chan, head)
|
data = get_memory(db, chan, head)
|
||||||
|
|
||||||
if tail[0] == '+' and len(tail) > 1:
|
if tail[0] == '+':
|
||||||
append = True
|
append = True
|
||||||
# ignore + symbol
|
# ignore + symbol
|
||||||
new = tail[1:]
|
new = tail[1:]
|
||||||
|
_head, _tail = data.split(None, 1)
|
||||||
# data is stored with the input so ignore it when re-adding it
|
# data is stored with the input so ignore it when re-adding it
|
||||||
tail = data.replace('"', "''")[2:] + ' ' + new
|
import string
|
||||||
|
if len(tail) > 1 and tail[1] in (string.punctuation + ' '):
|
||||||
|
tail = _tail + new
|
||||||
|
else:
|
||||||
|
tail = _tail + ' ' + new
|
||||||
|
|
||||||
db.execute("replace into memory(chan, word, data, nick) values"
|
db.execute("replace into memory(chan, word, data, nick) values"
|
||||||
" (?,lower(?),?,?)", (chan, head, head + ' ' + tail, nick))
|
" (?,lower(?),?,?)", (chan, head, head + ' ' + tail, nick))
|
||||||
|
@ -48,7 +53,7 @@ def remember(inp, nick='', chan='', db=None):
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
if append:
|
if append:
|
||||||
return "appending %s to %s" % (new, data.replace('"', "''")[2:])
|
return "appending %s to %s" % (new, data.replace('"', "''"))
|
||||||
else:
|
else:
|
||||||
return 'forgetting "%s", remembering this instead.' % \
|
return 'forgetting "%s", remembering this instead.' % \
|
||||||
data.replace('"', "''")
|
data.replace('"', "''")
|
||||||
|
|
Loading…
Reference in New Issue