aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-10 09:02:08 -0500
committerBlake DeMarcy <ofunknowndescent@gmail.com>2017-04-10 09:02:08 -0500
commit31ccd5c2322788c8fce0cc1aa58f7631a9e777ca (patch)
tree585343fbbb6d364c1fd4bc51d5f6238c46ebef05 /src
parent88f43d023a9fa31d2912a74c78c279ddded426ee (diff)
downloadbbj-31ccd5c2322788c8fce0cc1aa58f7631a9e777ca.tar.gz
add color options
Diffstat (limited to 'src')
-rw-r--r--src/db.py5
-rw-r--r--src/formatting.py29
2 files changed, 23 insertions, 11 deletions
diff --git a/src/db.py b/src/db.py
index 38d8cb0..5e86ff5 100644
--- a/src/db.py
+++ b/src/db.py
@@ -268,7 +268,8 @@ def user_update(connection, user_object, parameters):
user_id = user_object["user_id"]
for key in ("user_name", "auth_hash", "quip", "bio", "color"):
value = parameters.get(key)
- if value:
+ # bool(0) == False hur hur hurrrrrr ::drools::
+ if value == 0 or value:
validate([(key, value)])
user_object[key] = value
@@ -383,7 +384,7 @@ def validate(keys_and_values):
elif key == "color":
- if value in range(0, 6):
+ if value in range(0, 7):
continue
raise BBJParameterError(
"Color specification out of range (int 0-6)")
diff --git a/src/formatting.py b/src/formatting.py
index 755ef94..07250e8 100644
--- a/src/formatting.py
+++ b/src/formatting.py
@@ -16,13 +16,11 @@ markup = [
"bold", "italic", "underline", "strike"
]
-tokens = re.compile(
- r"\[({}): (.+?)]".format(
- "|".join(colors + markup)),
- flags=re.DOTALL)
+tokens = re.compile(r"\[(%s): (.+?)]" % "|".join(colors + markup),
+ flags=re.DOTALL)
-quotes = re.compile("&gt;&gt;([0-9]+)")
-linequotes = re.compile("^(&gt;.+)$",
+quotes = re.compile(">>([0-9]+)")
+linequotes = re.compile("^(>.+)$",
flags=re.MULTILINE)
@@ -31,9 +29,8 @@ def apply_formatting(msg_obj, formatter):
Receives a messages object from a thread and returns it with
all the message bodies passed through FORMATTER.
"""
- for x in msg_obj["messages"].keys():
- msg_obj["messages"][x]["body"] = \
- formatter(msg_obj["messages"][x]["body"])
+ for x in range(len(msg_obj)):
+ msg_obj[x]["body"] = formatter(msg_obj[x]["body"])
return msg_obj
@@ -44,6 +41,20 @@ def raw(text):
return text
+def strip(text):
+ """
+ Returns the text with all formatting directives removed.
+ Not to be confused with `raw`.
+ """
+
+
+
+def entities(text):
+ """
+ Returns a tuple where [0] is raw text
+ """
+
+
def html(text):
"""
Returns messages in html format, after being sent through markdown.
Un proyecto texto-plano.xyz