Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 851 - Twitter commands, r=aleth,fqueze.

This commit is contained in:
Patrick Cloke 2013-03-13 18:47:42 -04:00
Родитель d1768ca0bd
Коммит 0e40624157
3 изменённых файлов: 39 добавлений и 1 удалений

Просмотреть файл

@ -107,3 +107,6 @@ tooltip.listed_count=Listed
# These are used to turn true/false values into a yes/no response.
yes=Yes
no=No
command.follow=%S <username>[ <username>]*: Start following a user / users.
command.unfollow=%S <username>[ <username>]*: Stop following a user / users.

Просмотреть файл

@ -108,6 +108,8 @@ function ctcpCommand(aConv, aTarget, aCommand, aMsg) {
return true;
}
// Replace the command name in the help string so translators do not attempt to
// translate it.
var commands = [
{
name: "action",

Просмотреть файл

@ -1055,7 +1055,12 @@ Account.prototype = {
}
};
function TwitterProtocol() { }
// Shortcut to get the JavaScript account object.
function getAccount(aConv) aConv.wrappedJSObject._account;
function TwitterProtocol() {
this.registerCommands();
}
TwitterProtocol.prototype = {
__proto__: GenericProtocolPrototype,
get name() "Twitter",
@ -1064,6 +1069,34 @@ TwitterProtocol.prototype = {
options: {
"track": {get label() _("options.track"), default: ""}
},
// Replace the command name in the help string so translators do not attempt
// to translate it.
commands: [
{
name: "follow",
get helpString() _("command.follow", "follow"),
run: function(aMsg, aConv) {
aMsg = aMsg.trim();
if (!aMsg)
return false;
let account = getAccount(aConv);
aMsg.split(" ").forEach(account.follow, account);
return true;
}
},
{
name: "unfollow",
get helpString() _("command.unfollow", "unfollow"),
run: function(aMsg, aConv) {
aMsg = aMsg.trim();
if (!aMsg)
return false;
let account = getAccount(aConv);
aMsg.split(" ").forEach(account.stopFollowing, account);
return true;
}
}
],
getAccount: function(aImAccount) new Account(this, aImAccount),
classID: Components.ID("{31082ff6-1de8-422b-ab60-ca0ac0b2af13}")
};