Skip to content

Commit 06433d7

Browse files
committed
Factoids now support new IRC color formatting system.
1 parent 60c46ec commit 06433d7

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

plugins/factoids.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
1-
# Written by Scaevolus 2010
21
import string
32
import asyncio
43
import re
5-
from sqlalchemy import Table, Column, String
64

5+
from sqlalchemy import Table, Column, String
76
import requests
87

98
from cloudbot import hook
10-
from cloudbot.util import botvars, formatting, web
9+
from cloudbot.util import botvars, colors, web
10+
1111

1212
re_lineends = re.compile(r'[\r\n]*')
1313

1414
FACTOID_CHAR = "?" # TODO: config
1515

16-
# some simple "shortcodes" for formatting purposes
17-
shortcodes = {
18-
'[b]': '\x02',
19-
'[/b]': '\x02',
20-
'[u]': '\x1F',
21-
'[/u]': '\x1F',
22-
'[i]': '\x16',
23-
'[/i]': '\x16'
24-
}
25-
2616
table = Table(
2717
"mem",
2818
botvars.metadata,
@@ -153,7 +143,7 @@ def factoid(match, async, event, message, action):
153143

154144
if factoid_id in factoid_cache:
155145
data = factoid_cache[factoid_id]
156-
# factoid preprocessors
146+
# factoid pre-processors
157147
if data.startswith("<py>"):
158148
code = data[4:].strip()
159149
variables = 'input="""{}"""; nick="{}"; chan="{}"; bot_nick="{}";'.format(arguments.replace('"', '\\"'),
@@ -163,8 +153,8 @@ def factoid(match, async, event, message, action):
163153
else:
164154
result = data
165155

166-
# factoid postprocessors
167-
result = formatting.multi_replace(result, shortcodes)
156+
# factoid post-processors
157+
result = colors.parse(result)
168158

169159
if result.startswith("<act>"):
170160
result = result[5:].strip()

0 commit comments

Comments
 (0)