11 #include "wikiuser.hpp"
12 using namespace Huggle;
16 QRegExp
WikiUser::IPv6Regex(
"^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){8,})((?1)(?>:(?1)){0,6})?:"\
17 ":(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)"\
18 "?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\\.(?4)){3}))$");
20 QMutex WikiUser::ProblematicUserListLock(QMutex::Recursive);
24 WikiUser::ProblematicUserListLock.lock();
31 WikiUser::ProblematicUserListLock.unlock();
36 WikiUser::ProblematicUserListLock.unlock();
42 WikiUser::ProblematicUserListLock.lock();
56 WikiUser::ProblematicUserListLock.unlock();
61 WikiUser::ProblematicUserListLock.lock();
62 if (!us->IP && us->
getBadnessScore() <= Configuration::LocalConfig_WhitelistScore)
81 WikiUser::ProblematicUserListLock.unlock();
87 WikiUser::ProblematicUserListLock.unlock();
92 this->UserLock =
new QMutex(QMutex::Recursive);
96 this->WarningLevel = 0;
99 this->WhitelistInfo = 0;
105 this->UserLock =
new QMutex(QMutex::Recursive);
112 this->WhitelistInfo = u->WhitelistInfo;
116 WikiUser::WikiUser(
const WikiUser &u)
118 this->UserLock =
new QMutex(QMutex::Recursive);
125 this->WhitelistInfo = u.WhitelistInfo;
129 WikiUser::WikiUser(QString user)
131 this->UserLock =
new QMutex(QMutex::Recursive);
159 this->WarningLevel = 0;
164 WikiUser::~WikiUser()
176 WikiUser::ProblematicUserListLock.lock();
188 WikiUser::ProblematicUserListLock.unlock();
194 this->UserLock->lock();
199 QString contents =
"";
204 this->UserLock->unlock();
208 this->UserLock->unlock();
214 this->UserLock->lock();
217 this->UserLock->unlock();
222 WikiUser::ProblematicUserListLock.lock();
227 WikiUser::ProblematicUserListLock.unlock();
232 WikiUser::ProblematicUserListLock.unlock();
247 return Configuration::LocalConfig_NSUserTalk + this->
Username;
252 if (this->WhitelistInfo == 1)
256 if (this->WhitelistInfo == 2)
262 this->WhitelistInfo = 1;
266 this->WhitelistInfo = 2;
280 void WikiUser::setBadnessScore(
long value)
297 if (this->WarningLevel > 0)
320 flags +=
"-" + nflags;
324 flags +=
"+" + pflags;
328 bool WikiUser::GetBot()
const
333 void WikiUser::SetBot(
bool value)
QString GetContentsOfTalkPage()
GetContentsOfTalkPage returns a precached content of this users talk page If there is a global instan...
long BadnessScore
Badness score of current user.
void Update(bool MatchingOnly=false)
Call UpdateUser on current user.
bool IsIP()
Returns true in case the current user is IP user.
QString Username
Username.
long getBadnessScore(bool _resync=true)
Retrieve a badness score for current user, see WikiUser::BadnessScore for more.
static QRegExp IPv4Regex
Matches only IPv4.
static WikiUser * RetrieveUser(WikiUser *user)
Function that return static version of this user.
int WarningLevel
Current warning level of user.
void Resync()
Update the information of this user based on global user list.
static QStringList WhiteList
Data of wl.
bool IsWhitelisted()
Returns true if this user is wl.
static QList< WikiUser * > ProblematicUsers
List of users that are scored in this instance of huggle.
QString ContentsOfTalkPage
In case that we retrieved the talk page during parse of warning level, this string contains it...
static QRegExp IPv6Regex
Matches all IP.
QList< WikiEdit * > Contributions
Cache of contributions made by this user.
void ForceIP()
Change the IP property to true forcefully even if user isn't IP.
QString GetTalk()
Return a link to talk page of this user (like User talk:Jimbo)
static void TrimProblematicUsersList()
Delete all users that have badness score 0 these users aren't necessary to be stored in a list...
void SetContentsOfTalkPage(QString text)
SetContentsOfTalkPage Change a cache for talk page in local and global cache.
static void UpdateUser(WikiUser *us)
Update a list of problematic users.