1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
#include "baserules.h"
#include "ksopts.h"
#include "ksircprocess.h"
#include <tqregexp.h>
#include <stdio.h>
void KSMBaseRules::sirc_receive(TQCString, bool)
{
}
void KSMBaseRules::control_message(int, TQString)
{
}
filterRuleList *KSMBaseRules::defaultRules()
{
filterRule *fr;
filterRuleList *frl = new filterRuleList();
frl->setAutoDelete(TRUE);
if( ksopts->ksircColors ){
// 3 stage rule to filter:
// ~blah~<something> stuff with ~ here and ~ there
// Here's the path follows
// =>~blah~;;;<something> with ~ here and ~ there
// =>~blah~;;;<something> with ~~ here and ~~ there
// =>~blah~<something> with ~~ here and ~ there
// Basic problem was getting it not to change ~blah~ into ~~blah~~
fr = new filterRule();
fr->desc = "Add marker to second ~";
fr->search = "^~\\S+~";
fr->from = "^~(\\S+)~";
fr->to = "~;;;$1~;;;";
frl->append(fr);
fr = new filterRule();
fr->desc = "Escape kSirc Control Codes";
fr->search = "~";
fr->from = "(?g)~(?!;;;)";
fr->to = "$1~~";
frl->append(fr);
fr = new filterRule();
fr->desc = "Remove marker to second";
fr->search = "^~;;;\\S+~;;;";
fr->from = "^~;;;(\\S+)~;;;";
fr->to = "~$1~";
frl->append(fr);
}
else{
// If we don't escape all ~'s at least esacpe the ones in
// email/part joins etc.
fr = new filterRule();
fr->desc = "Search for dump ~'s";
fr->search = "\\W~\\S+@\\S+\\W";
fr->from = "~(\\S+@)";
fr->to = "~~$1";
frl->append(fr);
}
if(ksopts->mircColors){
fr = new filterRule();
fr->desc = "Remove mirc Colours";
fr->search = "\\x03";
fr->from = "(?g)\\x03(?:\\d{0,2},{0,1}\\d{0,2})";
fr->to = "";
frl->append(fr);
}
if( ksopts->nickForeground.isValid() || ksopts->nickColourization){
fr = new filterRule();
fr->desc = "Highlight nicks in colour";
fr->search = "(?:~\\S+~)[<>|\\[\\]\\-]\\S+[<>|\\[\\]\\-]";
fr->from = "^((?:~\\S+~))([<>|\\[\\]\\-])(\\S+)([<>|\\[\\]\\-])";
fr->to = "$1$2~n$3~n$4";
frl->append(fr);
fr = new filterRule();
fr->desc = "Highlight nicks in colour in CTCP ACTION";
fr->search = "(?:~\\S+~)\\* (\\S+)";
fr->from = "^((?:~\\S+~))\\* (\\S+)";
fr->to = "$1* ~n$2~n";
frl->append(fr);
}
if( ksopts->msgContainNick.isValid() ){
//TQString nick = ksopts->nick;
TQString nick = ksircProcess()->getNick();
if ( !nick.isEmpty() ) {
if(nick.length() > 83){
qDebug("Nick too long");
nick.truncate( 83 );
}
/*
* Since the nick is used in the regex we must
* escape all regex words
*/
nick = TQRegExp::escape(nick);
sprintf(match_us,
"(?i)<\\S+>.*\\s%s(,.*|\02:.*|:.*|\\s.*|$)", nick.latin1());
sprintf(to_us,
"$1~o");//, ksopts->ownNickColor);
fr = new filterRule();
fr->desc = "Highlight our nick";
fr->search = match_us;
fr->from = "(<\\S+>)";
fr->to = to_us;
frl->append(fr);
}
}
if( ksopts->msg1Contain.isValid() ){
//TQString nick = ksopts->nick;
/*
* Since the nick is used in the regex we must
* escape all regex words
*/
TQString msg = ksopts->msg1String;
if(msg.length() > 0){
if(ksopts->msg1Regex == false)
msg = TQRegExp::escape(msg);
snprintf(msg1_match, 100,
"(?i)<\\S+>.*\\s%s(,.*|\02:.*|:.*|\\s.*|$)", msg.latin1());
snprintf(msg1_to, 100,
"$1~%s", ksopts->msg1Contain.name().latin1());//, ksopts->ownNickColor);
fr = new filterRule();
fr->desc = "Highlight our msg1";
fr->search = msg1_match;
fr->from = "(<\\S+>)";
fr->to = msg1_to;
frl->append(fr);
}
}
if( ksopts->msg2Contain.isValid() ){
//TQString nick = ksopts->nick;
/*
* Since the nick is used in the regex we must
* escape all regex words
*/
TQString msg = ksopts->msg2String;
if(msg.length() > 0){
if(ksopts->msg2Regex == false)
msg = TQRegExp::escape(msg);
snprintf(msg2_match, 100,
"(?i)<\\S+>.*\\s%s(,.*|\02:.*|:.*|\\s.*|$)", msg.latin1());
snprintf(msg2_to, 100,
"$1~%s", ksopts->msg2Contain.name().latin1());//, ksopts->ownNickColor);
fr = new filterRule();
fr->desc = "Highlight our msg2";
fr->search = msg2_match;
fr->from = "(<\\S+>)";
fr->to = msg2_to;
frl->append(fr);
}
}
// Default rules alays in place
fr = new filterRule();
fr->desc = "Remove Just bold in parts and joins";
fr->search = "\\*\\x02\\S+\\x02\\*";
fr->from = "\\*\\x02(\\S+)\\x02\\*";
fr->to = "\\*$1\\*";
frl->append(fr);
return frl;
}
|