mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-09 22:37:55 +00:00
set/get preferred spam language
This commit is contained in:
parent
b14b6cf856
commit
67f3cd7ba5
@ -256,6 +256,8 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "getmentions", &getmentions, false, true, false },
|
{ "getmentions", &getmentions, false, true, false },
|
||||||
{ "setspammsg", &setspammsg, false, false, false },
|
{ "setspammsg", &setspammsg, false, false, false },
|
||||||
{ "getspammsg", &getspammsg, false, false, false },
|
{ "getspammsg", &getspammsg, false, false, false },
|
||||||
|
{ "setpreferredspamlang", &setpreferredspamlang, false, false, false },
|
||||||
|
{ "getpreferredspamlang", &getpreferredspamlang, false, false, false },
|
||||||
{ "follow", &follow, false, true, false },
|
{ "follow", &follow, false, true, false },
|
||||||
{ "unfollow", &unfollow, false, true, false },
|
{ "unfollow", &unfollow, false, true, false },
|
||||||
{ "getfollowing", &getfollowing, false, true, false },
|
{ "getfollowing", &getfollowing, false, true, false },
|
||||||
|
@ -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 getmentions(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value setspammsg(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 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 follow(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value unfollow(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);
|
extern json_spirit::Value getfollowing(const json_spirit::Array& params, bool fHelp);
|
||||||
|
@ -1490,7 +1490,7 @@ void receivedSpamMessage(std::string const &message, std::string const &user)
|
|||||||
{
|
{
|
||||||
LOCK(cs_spamMsg);
|
LOCK(cs_spamMsg);
|
||||||
bool hasSingleLangCode = (message.find("[") == message.rfind("["));
|
bool hasSingleLangCode = (message.find("[") == message.rfind("["));
|
||||||
bool hasPreferredLang = m_preferredSpamLang.length();
|
bool hasPreferredLang = m_preferredSpamLang.length() > 2;
|
||||||
bool isSameLang = hasPreferredLang && hasSingleLangCode &&
|
bool isSameLang = hasPreferredLang && hasSingleLangCode &&
|
||||||
message.find(m_preferredSpamLang) != string::npos;
|
message.find(m_preferredSpamLang) != string::npos;
|
||||||
bool currentlyEmpty = !m_receivedSpamMsgStr.length();
|
bool currentlyEmpty = !m_receivedSpamMsgStr.length();
|
||||||
@ -2325,6 +2325,38 @@ Value getspammsg(const Array& params, bool fHelp)
|
|||||||
return ret;
|
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)
|
Value follow(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || (params.size() != 2))
|
if (fHelp || (params.size() != 2))
|
||||||
|
Loading…
Reference in New Issue
Block a user