Tweaks
This commit is contained in:
parent
a1efe30f8f
commit
d8d270a076
1 changed files with 14 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
||||||
from util import hook, http
|
from util import hook, http
|
||||||
from util.text import multiword_replace
|
from util.text import multiword_replace
|
||||||
import string
|
import string
|
||||||
|
import sqlite3
|
||||||
import re
|
import re
|
||||||
|
|
||||||
re_lineends = re.compile(r'[\r\n]*')
|
re_lineends = re.compile(r'[\r\n]*')
|
||||||
|
@ -17,6 +18,7 @@ shortcodes = {
|
||||||
|
|
||||||
|
|
||||||
def python(data, args, input):
|
def python(data, args, input):
|
||||||
|
# this is all shit, replacement code is in the works
|
||||||
variables = "input='%s'; nick='%s'; chan='%s'; bot_nick='%s';" % (args,
|
variables = "input='%s'; nick='%s'; chan='%s'; bot_nick='%s';" % (args,
|
||||||
input.nick, input.chan, input.conn.nick)
|
input.nick, input.chan, input.conn.nick)
|
||||||
statement = variables + data
|
statement = variables + data
|
||||||
|
@ -81,14 +83,14 @@ def remember(inp, nick='', db=None, say=None, input=None, notice=None):
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
if append:
|
if append:
|
||||||
notice("Appending %s to %s" % (new, data.replace('"', "''")))
|
notice("Appending \x02%s\x02 to \x02%s\x02" % (new, data))
|
||||||
else:
|
else:
|
||||||
notice('Forgetting existing data (%s), remembering this instead!'
|
notice('Remembering \x02%s\x02 for \x02%s\x02. Type ?%s to see it.'
|
||||||
% data.replace('"', "''"))
|
% (tail, head, head))
|
||||||
return
|
notice('Previous data was \x02%s\x02' % data)
|
||||||
else:
|
else:
|
||||||
notice('Factoid created!')
|
notice('Remembering \x02%s\x02 for \x02%s\x02. Type ?%s to see it.'
|
||||||
return
|
% (tail, head, head))
|
||||||
|
|
||||||
|
|
||||||
@hook.command("f", adminonly=True)
|
@hook.command("f", adminonly=True)
|
||||||
|
@ -109,7 +111,8 @@ def forget(inp, db=None, input=None, notice=None):
|
||||||
notice("I don't know about that.")
|
notice("I don't know about that.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@hook.command()
|
|
||||||
|
@hook.command
|
||||||
def info(inp, notice=None, db=None):
|
def info(inp, notice=None, db=None):
|
||||||
"info <factoid> -- Shows the source of a factoid."
|
"info <factoid> -- Shows the source of a factoid."
|
||||||
|
|
||||||
|
@ -121,7 +124,7 @@ def info(inp, notice=None, db=None):
|
||||||
if data:
|
if data:
|
||||||
notice(data)
|
notice(data)
|
||||||
else:
|
else:
|
||||||
notice("Unknown Factoid")
|
notice("Unknown Factoid.")
|
||||||
|
|
||||||
|
|
||||||
@hook.regex(r'^\? ?(.+)')
|
@hook.regex(r'^\? ?(.+)')
|
||||||
|
@ -146,7 +149,6 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
||||||
data = get_memory(db, factoid_id)
|
data = get_memory(db, factoid_id)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
|
|
||||||
# if the factoid starts with <py>, its a dynamic one
|
# if the factoid starts with <py>, its a dynamic one
|
||||||
if data.startswith("<py>"):
|
if data.startswith("<py>"):
|
||||||
result = python(data[4:].strip(), arguments, input)
|
result = python(data[4:].strip(), arguments, input)
|
||||||
|
|
Reference in a new issue