From d9324eaf959ebe7d0949c2897cc1f372430a1d2b Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 14:12:21 +0800 Subject: [PATCH 01/10] bbcode style formatting. --- plugins/util/ircformat.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/util/ircformat.py diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py new file mode 100644 index 0000000..6024564 --- /dev/null +++ b/plugins/util/ircformat.py @@ -0,0 +1,21 @@ +def bb(format_string): + rep = {'[b]':'\x02', + '[White]':'\x030', + '[Black]':'\x031', + '[dBlue]':'\x032', + '[dGreen]':'\x033', + '[dRed]':'\x034', + '[Brown]':'\x035', + '[Purple]':'\x036', + '[Gold]':'\x037', + 'Yellow':'\x038', + '[Green]':'\x039', + '[Cyan]':'\x0310', + '[lBlue]':'\x0311', + '[Blue]':'\x0312', + '[Pink]':'\x0313', + '[Gray]':'\x0314', + '[lGray]':'\x0315',} + for x in rep: + format_string = format_string.replace(x,rep[x]) + return format_string From 2103c64dd5a3cbab2f05b62016ce4e015673862f Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 14:23:33 +0800 Subject: [PATCH 02/10] Added multiple code sets. Future proofed code set adding. --- plugins/util/ircformat.py | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index 6024564..1c9b0d9 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -1,21 +1,26 @@ def bb(format_string): - rep = {'[b]':'\x02', - '[White]':'\x030', - '[Black]':'\x031', - '[dBlue]':'\x032', - '[dGreen]':'\x033', - '[dRed]':'\x034', - '[Brown]':'\x035', - '[Purple]':'\x036', - '[Gold]':'\x037', - 'Yellow':'\x038', - '[Green]':'\x039', - '[Cyan]':'\x0310', - '[lBlue]':'\x0311', - '[Blue]':'\x0312', - '[Pink]':'\x0313', - '[Gray]':'\x0314', - '[lGray]':'\x0315',} - for x in rep: + stuff = {} + stuff['col'] = {'[white]':'\x030', + '[black]':'\x031', + '[dblue]':'\x032', + '[dgreen]':'\x033', + '[dred]':'\x034', + '[brown]':'\x035', + '[purple]':'\x036', + '[gold]':'\x037', + '[yellow]':'\x038', + '[green]':'\x039', + '[cyan]':'\x0310', + '[lblue]':'\x0311', + '[blue]':'\x0312', + '[pink]':'\x0313', + '[gray]':'\x0314', + '[lgray]':'\x0315',} + stuff['style'] = {'[b]':'\x02'} + stuff['sym'] = {'[point]':'\x07'} + final = {} + for x in stuff: + final.update(x) + for x in final: format_string = format_string.replace(x,rep[x]) return format_string From 14530f07f1fd5aa73f1dded620670ad52644ed0a Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 14:54:50 +0800 Subject: [PATCH 03/10] Added text set. --- plugins/util/ircformat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index 1c9b0d9..a827dd3 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -18,6 +18,7 @@ def bb(format_string): '[lgray]':'\x0315',} stuff['style'] = {'[b]':'\x02'} stuff['sym'] = {'[point]':'\x07'} + stuff['text'] = {'[url]':'http://'} final = {} for x in stuff: final.update(x) From 07b5abff7bd8767ea1d8f2ac574beda600f62f86 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 14:57:26 +0800 Subject: [PATCH 04/10] bb moved to more descriptive rep. --- plugins/util/ircformat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index a827dd3..5cd5444 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -1,4 +1,4 @@ -def bb(format_string): +def rep(format_string): stuff = {} stuff['col'] = {'[white]':'\x030', '[black]':'\x031', From 2fb0f811b85726ca91062b1a02ac7cc61dbe0621 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 14:59:07 +0800 Subject: [PATCH 05/10] Docstring and typo fix. --- plugins/util/ircformat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index 5cd5444..20f32d2 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -1,4 +1,5 @@ def rep(format_string): + """Replace based irc formatting""" stuff = {} stuff['col'] = {'[white]':'\x030', '[black]':'\x031', @@ -23,5 +24,5 @@ def rep(format_string): for x in stuff: final.update(x) for x in final: - format_string = format_string.replace(x,rep[x]) + format_string = format_string.replace(x,final[x]) return format_string From 5f87bf0e7624e9cd16a63587bfdd5c1af565cba4 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 15:06:00 +0800 Subject: [PATCH 06/10] Added base context styling. --- plugins/util/ircformat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index 20f32d2..9c21018 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -16,7 +16,9 @@ def rep(format_string): '[blue]':'\x0312', '[pink]':'\x0313', '[gray]':'\x0314', - '[lgray]':'\x0315',} + '[lgray]':'\x0315', + '[err]':'\x034\x02' + '[/err]':'\x030\x02'} stuff['style'] = {'[b]':'\x02'} stuff['sym'] = {'[point]':'\x07'} stuff['text'] = {'[url]':'http://'} @@ -26,3 +28,6 @@ def rep(format_string): for x in final: format_string = format_string.replace(x,final[x]) return format_string +def err(format_string): + """Format the string with standard error styling""" + return "\x034\x02{}\x030\x02".format(format_string) \ No newline at end of file From 75d4af13932c7bc8b8b6459febe577c3429e1847 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 15:10:39 +0800 Subject: [PATCH 07/10] ircformat.raw makes more sense with the addition of ircformat.err. --- plugins/util/ircformat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index 9c21018..be5c400 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -1,4 +1,4 @@ -def rep(format_string): +def raw(format_string): """Replace based irc formatting""" stuff = {} stuff['col'] = {'[white]':'\x030', From d29b3c313f6ef52a6a14c009535064812ffe1462 Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 15:40:08 +0800 Subject: [PATCH 08/10] Fixing dict.update() --- plugins/util/ircformat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index be5c400..e08f291 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -24,7 +24,7 @@ def raw(format_string): stuff['text'] = {'[url]':'http://'} final = {} for x in stuff: - final.update(x) + final.update(stuff[x]) for x in final: format_string = format_string.replace(x,final[x]) return format_string From 893f621dd025febdd636f2349a37b35686aa98de Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 16:10:48 +0800 Subject: [PATCH 09/10] Added clear, updated err. --- plugins/util/ircformat.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/util/ircformat.py b/plugins/util/ircformat.py index e08f291..442adf5 100644 --- a/plugins/util/ircformat.py +++ b/plugins/util/ircformat.py @@ -19,7 +19,8 @@ def raw(format_string): '[lgray]':'\x0315', '[err]':'\x034\x02' '[/err]':'\x030\x02'} - stuff['style'] = {'[b]':'\x02'} + stuff['style'] = {'[b]':'\x02', + '[clear]':'\x0f'} stuff['sym'] = {'[point]':'\x07'} stuff['text'] = {'[url]':'http://'} final = {} @@ -30,4 +31,4 @@ def raw(format_string): return format_string def err(format_string): """Format the string with standard error styling""" - return "\x034\x02{}\x030\x02".format(format_string) \ No newline at end of file + return "\x034\x02{}\x0f".format(format_string) \ No newline at end of file From c2d021a07a5685888a45b6ba6f9eab9176fcb6bf Mon Sep 17 00:00:00 2001 From: Fletcher Boyd Date: Fri, 6 Sep 2013 17:06:52 +0800 Subject: [PATCH 10/10] better name. --- plugins/util/{ircformat.py => formatting.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/util/{ircformat.py => formatting.py} (100%) diff --git a/plugins/util/ircformat.py b/plugins/util/formatting.py similarity index 100% rename from plugins/util/ircformat.py rename to plugins/util/formatting.py