]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/irc/commands.js
d13920f8c1e4a118d39c990c4edf9ce61855c217
1 qwebirc
.irc
.Commands
= new Class({
2 Extends: qwebirc
.irc
.BaseCommandParser
,
3 initialize: function(parentObject
) {
4 this.parent(parentObject
);
6 this.aliases
= new QHash({
12 "PRIVACY": "PRIVACYPOLICY",
20 newUIWindow: function(property
) {
21 var p
= this.parentObject
.ui
[property
];
23 this.getActiveWindow().errorMessage("Current UI does not support that command.");
25 p
.bind(this.parentObject
.ui
)();
29 /* [require_active_window, splitintoXargs, minargs, function] */
30 cmd_ME: [true, undefined, undefined, function(args
) {
34 var target
= this.getActiveWindow().name
;
35 if(!this.send("PRIVMSG " + target
+ " :\x01ACTION " + args
+ "\x01"))
38 this.newQueryLine(target
, "ACTION", args
, {"@": this.parentObject
.getNickStatus(target
, this.parentObject
.nickname
)});
40 cmd_CTCP: [false, 3, 2, function(args
) {
42 var type
= args
[1].toUpperCase();
43 var message
= args
[2];
45 if(message
== undefined)
49 if(!this.send("PRIVMSG " + target
+ " :\x01" + type
+ "\x01"))
52 if(!this.send("PRIVMSG " + target
+ " :\x01" + type
+ " " + message
+ "\x01"))
56 this.newTargetLine(target
, "CTCP", message
, {"x": type
});
58 cmd_PRIVMSG: [false, 2, 2, function(args
) {
60 var message
= args
[1];
62 if(!this.parentObject
.isChannel(target
))
63 this.parentObject
.pushLastNick(target
);
64 if(this.send("PRIVMSG " + target
+ " :" + message
))
65 this.newQueryLine(target
, "MSG", message
, {"@": this.parentObject
.getNickStatus(target
, this.parentObject
.nickname
)});
67 cmd_NOTICE: [false, 2, 2, function(args
) {
69 var message
= args
[1];
71 if(this.send("NOTICE " + target
+ " :" + message
)) {
72 if(this.parentObject
.isChannel(target
)) {
73 this.newTargetLine(target
, "NOTICE", message
, {"@": this.parentObject
.getNickStatus(target
, this.parentObject
.nickname
)});
75 this.newTargetLine(target
, "NOTICE", message
);
79 cmd_QUERY: [false, 2, 1, function(args
) {
80 if(this.parentObject
.isChannel(args
[0])) {
81 this.getActiveWindow().errorMessage("Can't target a channel with this command.");
85 this.parentObject
.newWindow(args
[0], qwebirc
.ui
.WINDOW_QUERY
, true);
87 if((args
.length
> 1) && (args
[1] != ""))
88 return ["SAY", args
[1]];
90 cmd_SAY: [true, undefined, undefined, function(args
) {
94 return ["PRIVMSG", this.getActiveWindow().name
+ " " + args
]
96 cmd_IGNORE: [false, 1, 0, function(args
) {
97 var w
= this.getActiveWindow();
98 var info
= w
.infoMessage
.bind(w
);
99 if(!args
|| args
.length
== 0) {
100 var l
= this.parentObject
.getIgnoreList();
102 info("IGNOREEMPTY", "");
104 info("IGNOREHEADER", "");
105 l
.forEach(function(v
) {
106 info("IGNOREENTRY", {"h": v
});
111 this.parentObject
.ignore(nick
);
112 info("IGNORED", {"n": nick
});
115 cmd_UNIGNORE: [false, 1, 1, function(args
) {
117 this.parentObject
.unignore(nick
);
118 this.parentObject
.getActiveWindow().infoMessage("UNIGNORED", {"n": nick
});
120 cmd_LOGOUT: [false, undefined, undefined, function(args
) {
121 this.parentObject
.ui
.logout();
123 cmd_OPTIONS: [false, undefined, undefined, function(args
) {
124 this.newUIWindow("optionsWindow");
126 cmd_EMBED: [false, undefined, undefined, function(args
) {
127 this.newUIWindow("embeddedWindow");
129 cmd_PRIVACYPOLICY: [false, undefined, undefined, function(args
) {
130 this.newUIWindow("privacyWindow");
132 cmd_ABOUT: [false, undefined, undefined, function(args
) {
133 this.newUIWindow("aboutWindow");
135 cmd_QUOTE: [false, 1, 1, function(args
) {
138 cmd_KICK: [true, 2, 1, function(args
) {
139 var channel
= this.getActiveWindow().name
;
142 var target
= args
[0];
147 this.send("KICK " + channel
+ " " + target
+ " :" + message
);
149 automode: function(direction
, mode
, args
) {
150 var channel
= this.getActiveWindow().name
;
152 var modes
= direction
;
153 for(var i
=0;i
<args
.length
;i
++)
154 modes
= modes
+ mode
;
156 this.send("MODE " + channel
+ " " + modes
+ " " + args
.join(" "));
158 cmd_OP: [true, 6, 1, function(args
) {
159 this.automode("+", "o", args
);
161 cmd_DEOP: [true, 6, 1, function(args
) {
162 this.automode("-", "o", args
);
164 cmd_VOICE: [true, 6, 1, function(args
) {
165 this.automode("+", "v", args
);
167 cmd_DEVOICE: [true, 6, 1, function(args
) {
168 this.automode("-", "v", args
);
170 cmd_TOPIC: [true, 1, 1, function(args
) {
171 var w
= this.getActiveWindow();
172 if(w
.client
.isChannel(args
[0])) {
173 this.send("TOPIC " + args
[0]);
175 this.send("TOPIC " + w
.name
+ " :" + args
[0]);
178 cmd_AWAY: [false, 1, 0, function(args
) {
179 this.send("AWAY :" + (args
?args
[0]:""));
181 cmd_QUIT: [false, 1, 0, function(args
) {
182 this.send("QUIT :" + (args
?args
[0]:""));
184 cmd_CYCLE: [true, 1, 0, function(args
) {
185 var c
= this.getActiveWindow().name
;
187 this.send("PART " + c
+ " :" + (args
?args
[0]:"rejoining. . ."));
188 this.send("JOIN " + c
);
190 cmd_JOIN: [false, 2, 1, function(args
) {
191 var channels
= args
.shift();
193 var schans
= channels
.split(",");
198 schans
.forEach(function(x
) {
199 if(!this.parentObject
.isChannel(x
)) {
207 var delayinfo = function() {
208 this.getActiveWindow().infoMessage("Channel names begin with # (corrected automatically).");
209 }.bind(this).delay(250);
212 this.send("JOIN " + fchans
.join(",") + " " + args
.join(" "));
214 cmd_UMODE: [false, 1, 0, function(args
) {
215 this.send("MODE " + this.parentObject
.getNickname() + (args
?(" " + args
[0]):""));
217 cmd_BEEP: [false, undefined, undefined, function(args
) {
218 this.parentObject
.ui
.beep();
220 cmd_AUTOJOIN: [false, undefined, undefined, function(args
) {
221 return ["JOIN", this.parentObject
.options
.autojoin
];
223 cmd_HELP: [false, undefined, undefined, function(args
) {
224 if(qwebirc
.global
.helpURL
) {
225 this.newUIWindow("helpWindow");
227 this.send("HELP" + (args
? (" " + args
[0]) : ""));
230 cmd_CLEAR: [false, undefined, undefined, function(args
) {
231 var w
= this.getActiveWindow().lines
;
232 while(w
.childNodes
.length
> 0)
233 w
.removeChild(w
.firstChild
);
235 cmd_PART: [false, 2, 0, function(args
) {
236 var w
= this.getActiveWindow();
240 if(w
.type
!= qwebirc
.ui
.WINDOW_CHANNEL
) {
241 if(!args
|| args
.length
== 0) {
242 w
.errorMessage("Insufficient arguments for command.");
249 if(!args
|| args
.length
== 0) {
252 var isChan
= this.parentObject
.isChannel(args
[0]);
259 message
= args
.join(" ");
264 this.send("PART " + channel
+ " :" + message
);