Browse Source

set/get preferred spam language

miguelfreitas
Miguel Freitas 10 years ago
parent
commit
67f3cd7ba5
  1. 2
      src/bitcoinrpc.cpp
  2. 2
      src/bitcoinrpc.h
  3. 34
      src/twister.cpp

2
src/bitcoinrpc.cpp

@ -256,6 +256,8 @@ static const CRPCCommand vRPCCommands[] = @@ -256,6 +256,8 @@ static const CRPCCommand vRPCCommands[] =
{ "getmentions", &getmentions, false, true, false },
{ "setspammsg", &setspammsg, false, false, false },
{ "getspammsg", &getspammsg, false, false, false },
{ "setpreferredspamlang", &setpreferredspamlang, false, false, false },
{ "getpreferredspamlang", &getpreferredspamlang, false, false, false },
{ "follow", &follow, false, true, false },
{ "unfollow", &unfollow, false, true, false },
{ "getfollowing", &getfollowing, false, true, false },

2
src/bitcoinrpc.h

@ -209,6 +209,8 @@ extern json_spirit::Value getdirectmsgs(const json_spirit::Array& params, bool f @@ -209,6 +209,8 @@ extern json_spirit::Value getdirectmsgs(const json_spirit::Array& params, bool f
extern json_spirit::Value getmentions(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value setspammsg(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getspammsg(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value setpreferredspamlang(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getpreferredspamlang(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value follow(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value unfollow(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getfollowing(const json_spirit::Array& params, bool fHelp);

34
src/twister.cpp

@ -1490,7 +1490,7 @@ void receivedSpamMessage(std::string const &message, std::string const &user) @@ -1490,7 +1490,7 @@ void receivedSpamMessage(std::string const &message, std::string const &user)
{
LOCK(cs_spamMsg);
bool hasSingleLangCode = (message.find("[") == message.rfind("["));
bool hasPreferredLang = m_preferredSpamLang.length();
bool hasPreferredLang = m_preferredSpamLang.length() > 2;
bool isSameLang = hasPreferredLang && hasSingleLangCode &&
message.find(m_preferredSpamLang) != string::npos;
bool currentlyEmpty = !m_receivedSpamMsgStr.length();
@ -2325,6 +2325,38 @@ Value getspammsg(const Array& params, bool fHelp) @@ -2325,6 +2325,38 @@ Value getspammsg(const Array& params, bool fHelp)
return ret;
}
Value setpreferredspamlang(const Array& params, bool fHelp)
{
if (fHelp || (params.size() != 1))
throw runtime_error(
"setpreferredspamlang <langcode>\n"
"Set preferred spam language (or 'none')");
string strLangCode = params[0].get_str();
if (strLangCode == "none") {
m_preferredSpamLang = "[]";
} else {
if( strLangCode.find("[") == string::npos ) {
m_preferredSpamLang = "[" + strLangCode + "]";
} else {
m_preferredSpamLang = strLangCode;
}
}
return Value();
}
Value getpreferredspamlang(const Array& params, bool fHelp)
{
if (fHelp || (params.size() != 0))
throw runtime_error(
"getpreferredspamlang\n"
"get preferred spam language");
return Value(m_preferredSpamLang);
}
Value follow(const Array& params, bool fHelp)
{
if (fHelp || (params.size() != 2))

Loading…
Cancel
Save