Changeset 415:c17256e1dc79
- Timestamp:
- 06/21/2010 03:18:21 PM (20 months ago)
- Author:
- Sidgyck <sidgyck@…>
- Branch:
- default
- Message:
-
[NEW]: "!muc visits[ex] [from] [to]" show conference visits
- Location:
- src/plugins/muc
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r414
|
r415
|
|
| 156 | 156 | myVisitor->removeExpired(); |
| 157 | 157 | myModerator->removeExpired(); |
| | 158 | } |
| | 159 | |
| | 160 | QStringList |
| | 161 | Conference::visits(const QDateTime& from, const QDateTime& to, bool ext, int limit) |
| | 162 | { |
| | 163 | QSqlQuery query=DataStorage::instance() |
| | 164 | ->prepareQuery("SELECT nick, lastaction FROM conference_nicks WHERE conference_id=? " |
| | 165 | "AND lastaction BETWEEN ? AND ? ORDER BY lastaction LIMIT ?"); |
| | 166 | query.addBindValue(id()); |
| | 167 | query.addBindValue(from); |
| | 168 | query.addBindValue(to); |
| | 169 | query.addBindValue(limit); |
| | 170 | |
| | 171 | QStringList list; |
| | 172 | if (!query.exec()) |
| | 173 | return list; |
| | 174 | |
| | 175 | while (query.next()) |
| | 176 | { |
| | 177 | list.append((ext) ? query.value(0).toString()+" (" |
| | 178 | + query.value(1).toDateTime().toString("dd.MM.yyyy HH:mm") |
| | 179 | + ")" : query.value(0).toString()); |
| | 180 | } |
| | 181 | return list; |
| 158 | 182 | } |
| 159 | 183 | |
-
|
r414
|
r415
|
|
| 44 | 44 | QString seen(const QString& nick, bool ext = false, bool byjid = false); |
| 45 | 45 | QString clientStat(); |
| | 46 | QStringList visits(const QDateTime& from, const QDateTime& to, bool ext = false, int limit = 100); |
| 46 | 47 | void setNick(const QString& name); |
| 47 | 48 | void setLazyLeave(bool value); |
-
|
r414
|
r415
|
|
| 42 | 42 | commands << "REPORT" << "MISSING" << "STAT"; |
| 43 | 43 | |
| 44 | | commands << "POKE" << "REALJID" << "INVITE" << "CLEAN" << "TOPIC"; |
| | 44 | commands << "POKE" << "REALJID" << "INVITE" << "CLEAN" << "TOPIC" << "VISITS"; |
| 45 | 45 | pluginId=1; |
| 46 | 46 | |
| … |
… |
|
| 631 | 631 | myShouldIgnoreError=1; |
| 632 | 632 | return false; |
| | 633 | } |
| | 634 | |
| | 635 | if (cmd=="VISITS" || cmd=="VISITSEX") |
| | 636 | { |
| | 637 | Conference* conf = getConf(s); |
| | 638 | if (!conf) { |
| | 639 | reply(s, "You are not in conference!"); |
| | 640 | return true; |
| | 641 | } |
| | 642 | QString arg2 = parser.nextToken(); |
| | 643 | QStringList list; |
| | 644 | QDateTime from = QDateTime::fromString(arg, Qt::ISODate); |
| | 645 | QDateTime to = QDateTime::fromString(arg2, Qt::ISODate); |
| | 646 | if (!to.isValid()) |
| | 647 | to = QDateTime::currentDateTime(); |
| | 648 | if (!from.isValid()) |
| | 649 | from = QDateTime(to.date()); |
| | 650 | |
| | 651 | if (from > to) |
| | 652 | { |
| | 653 | QDateTime tmp = from; |
| | 654 | from = to; |
| | 655 | to = tmp; |
| | 656 | } |
| | 657 | list = conf->visits(from, to, cmd.endsWith("EX")); |
| | 658 | reply(s, QString("over the past %1 there was %2 user%3: %4") |
| | 659 | .arg(secsToString(from.secsTo(to))) |
| | 660 | .arg( list.count() ) |
| | 661 | .arg( list.count() > 1 ?"s":"" ) |
| | 662 | .arg( list.join(", ")) ); |
| | 663 | return true; |
| 633 | 664 | } |
| 634 | 665 | |