mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Add a glitch text command
This commit is contained in:
parent
0649bc342d
commit
99bbe26609
5 changed files with 36 additions and 0 deletions
|
@ -91,6 +91,8 @@ CommandCompleter::data(const QModelIndex &index, int role) const
|
||||||
return QStringLiteral("/rainfall ");
|
return QStringLiteral("/rainfall ");
|
||||||
case Msgtype:
|
case Msgtype:
|
||||||
return QStringLiteral("/msgtype ");
|
return QStringLiteral("/msgtype ");
|
||||||
|
case Glitch:
|
||||||
|
return QStringLiteral("/glitch ");
|
||||||
case Goto:
|
case Goto:
|
||||||
return QStringLiteral("/goto ");
|
return QStringLiteral("/goto ");
|
||||||
case ConvertToDm:
|
case ConvertToDm:
|
||||||
|
@ -170,6 +172,8 @@ CommandCompleter::data(const QModelIndex &index, int role) const
|
||||||
return tr("/msgtype <msgtype> [message]");
|
return tr("/msgtype <msgtype> [message]");
|
||||||
case Goto:
|
case Goto:
|
||||||
return tr("/goto <message reference>");
|
return tr("/goto <message reference>");
|
||||||
|
case Glitch:
|
||||||
|
return tr("/glitch <message>");
|
||||||
case ConvertToDm:
|
case ConvertToDm:
|
||||||
return QStringLiteral("/converttodm");
|
return QStringLiteral("/converttodm");
|
||||||
case ConvertToRoom:
|
case ConvertToRoom:
|
||||||
|
@ -245,6 +249,8 @@ CommandCompleter::data(const QModelIndex &index, int role) const
|
||||||
return tr("Send a message with rain.");
|
return tr("Send a message with rain.");
|
||||||
case Msgtype:
|
case Msgtype:
|
||||||
return tr("Send a message with a custom message type.");
|
return tr("Send a message with a custom message type.");
|
||||||
|
case Glitch:
|
||||||
|
return tr("Send a message with a glitch effect.");
|
||||||
case Goto:
|
case Goto:
|
||||||
return tr("Go to a specific message using an event id, index or matrix: link");
|
return tr("Go to a specific message using an event id, index or matrix: link");
|
||||||
case ConvertToDm:
|
case ConvertToDm:
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
RainbowConfetti,
|
RainbowConfetti,
|
||||||
Rainfall,
|
Rainfall,
|
||||||
Msgtype,
|
Msgtype,
|
||||||
|
Glitch,
|
||||||
Goto,
|
Goto,
|
||||||
ConvertToDm,
|
ConvertToDm,
|
||||||
ConvertToRoom,
|
ConvertToRoom,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
#include <QRandomGenerator64>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
@ -2012,3 +2013,25 @@ utils::removeExpiredEvents()
|
||||||
|
|
||||||
ApplyEventExpiration::next(std::move(asus));
|
ApplyEventExpiration::next(std::move(asus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
utils::glitchText(const QString &text)
|
||||||
|
{
|
||||||
|
static const QList<QChar> diacritics = []() {
|
||||||
|
QList<QChar> ret;
|
||||||
|
for (wchar_t c = u'\u0300'; c <= u'\u036f'; ++c)
|
||||||
|
ret.append(QChar(c));
|
||||||
|
return ret;
|
||||||
|
}();
|
||||||
|
|
||||||
|
QString result;
|
||||||
|
|
||||||
|
for (int i = 0; i < text.size(); ++i) {
|
||||||
|
result.append(text.at(i));
|
||||||
|
if (QRandomGenerator64::global()->bounded(0, 100) >= 25)
|
||||||
|
result.append(
|
||||||
|
diacritics.at(QRandomGenerator64::global()->bounded(0, diacritics.size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -205,4 +205,7 @@ updateSpaceVias();
|
||||||
|
|
||||||
void
|
void
|
||||||
removeExpiredEvents();
|
removeExpiredEvents();
|
||||||
|
|
||||||
|
QString
|
||||||
|
glitchText(const QString &text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,7 @@ InputBar::updateTextContentProperties(const QString &t)
|
||||||
QStringLiteral("rainbowconfetti"),
|
QStringLiteral("rainbowconfetti"),
|
||||||
QStringLiteral("rainfall"),
|
QStringLiteral("rainfall"),
|
||||||
QStringLiteral("msgtype"),
|
QStringLiteral("msgtype"),
|
||||||
|
QStringLiteral("glitch"),
|
||||||
QStringLiteral("goto"),
|
QStringLiteral("goto"),
|
||||||
QStringLiteral("converttodm"),
|
QStringLiteral("converttodm"),
|
||||||
QStringLiteral("converttoroom"),
|
QStringLiteral("converttoroom"),
|
||||||
|
@ -918,6 +919,8 @@ InputBar::command(const QString &command, QString args)
|
||||||
rainfall(args);
|
rainfall(args);
|
||||||
} else if (command == QLatin1String("msgtype")) {
|
} else if (command == QLatin1String("msgtype")) {
|
||||||
customMsgtype(args.section(' ', 0, 0), args.section(' ', 1, -1));
|
customMsgtype(args.section(' ', 0, 0), args.section(' ', 1, -1));
|
||||||
|
} else if (command == QLatin1String("glitch")) {
|
||||||
|
message(utils::glitchText(args));
|
||||||
} else if (command == QLatin1String("goto")) {
|
} else if (command == QLatin1String("goto")) {
|
||||||
// Goto has three different modes:
|
// Goto has three different modes:
|
||||||
// 1 - Going directly to a given event ID
|
// 1 - Going directly to a given event ID
|
||||||
|
|
Loading…
Reference in a new issue