11 #include "vandalnw.hpp"
12 #include "ui_vandalnw.h"
14 using namespace Huggle;
19 this->ui->setupUi(
this);
20 this->
pref = QString(QChar(001)) + QString(QChar(001));
21 this->
tm =
new QTimer(
this);
22 this->JoinedMain =
false;
23 connect(
tm, SIGNAL(timeout()),
this, SLOT(
onTick()));
37 if (!Configuration::VandalNw_Login)
40 Core::Log(
"Vandalism network isn't allowed in options");
45 this->
Insert(
"Connecting to huggle anti vandalism network");
52 this->Irc->Disconnect();
54 this->
Insert(
"You are disconnected from HAN");
59 this->Irc->Send(this->GetChannel(), this->
pref +
"GOOD " + QString::number(Edit->
RevID));
64 this->Irc->Send(this->GetChannel(), this->
pref +
"ROLLBACK " + QString::number(Edit->
RevID));
67 void VandalNw::SuspiciousWikiEdit(
WikiEdit *Edit)
69 this->Irc->Send(this->GetChannel(), this->
pref +
"SUSPICIOUS " + QString::number(Edit->
RevID));
72 void VandalNw::WarningSent(
WikiUser *user,
int Level)
74 this->Irc->Send(this->GetChannel(), this->
pref +
"WARN " + QString::number(Level) +
" " + QUrl::toPercentEncoding(user->
Username));
77 QString VandalNw::GetChannel()
87 this->
Insert(
"Lost connection to antivandalism network");
93 this->JoinedMain =
true;
95 this->
Insert(
"You are now connected to huggle antivandalism network");
96 this->Irc->Join(this->GetChannel());
101 if (m->Text.startsWith(
pref))
103 QString Command = m->Text.mid(2);
104 if (m->Text.contains(
" "))
106 Command = Command.mid(0, Command.indexOf(
" "));
107 QString revid = m->Text.mid(m->Text.indexOf(
" ") + 1);
108 if (Command ==
"GOOD")
110 int RevID = revid.toInt();
112 this->
Insert(m->user.Nick +
" seen a good edit " + revid);
114 if (Command ==
"ROLLBACK")
116 int RevID = revid.toInt();
118 this->
Insert(m->user.Nick +
" did a rollback of " + revid);
120 if (Command ==
"SUSPICIOUS")
123 this->
Insert(m->user.Nick +
" thinks that edit " + revid +
" is likely a vandalism, but they didn't revert it");
129 this->
Insert(m->user.Nick +
": " + m->Text);
137 QString t = ui->textEdit->toPlainText();
138 t.prepend(text +
"\n");
140 ui->textEdit->setPlainText(t);
143 void Huggle::VandalNw::on_pushButton_clicked()
145 if (this->Irc->IsConnected())
147 this->Irc->Send(this->GetChannel(), this->ui->lineEdit->text());
150 ui->lineEdit->setText(
"");
static QString HuggleVersion
Version.
static void Log(QString Message)
Write text to terminal as well as ring log.
static QString UserName
User name.
Represent a message on irc network sent either to a channel or to a user.
void Rollback(WikiEdit *Edit)
Notify others about a rollback of edit.
void Good(WikiEdit *Edit)
This will deliver an edit to others as a good edit.
bool IsConnected()
IsConnected checks for connection.
The NetworkIrc provides connection to IRC servers.
QString Username
Username.
QString IRCChannel
IRC channel of this site, if it doesn't have a channel leave it empty.
HuggleQueue * Queue1
Pointer to queue.
static WikiSite Project
currently selected project
VandalNw(QWidget *parent=0)
void Connect()
Connect to server.
static MainWindow * Main
Pointer to main.
void Insert(QString text)
Insert text to window.