return $this->command == 'PRIVMSG';
}
+ public function isRoomstate() {
+ return $this->command == 'ROOMSTATE';
+ }
+
public function isWhisper() {
return $this->command == 'WHISPER';
}
return $this->isOwner() || (isset($this->tags['mod']) && $this->tags['mod'] == '1');
}
+ public function hasTag($name) {
+ return array_key_exists($name, $this->tags);
+ }
+
+ public function getTag($name) {
+ return $this->tags[$name];
+ }
+
public function makePong() {
$msg = new IRCMessage();
$msg->command = 'PONG';
$this->handleWhisper($msg);
return;
}
+ if ($msg->isRoomstate()) {
+ $this->handleRoomstate($msg);
+ return;
+ }
if ($msg->isNotice() && $msg->getText() == 'Login authentication failed') {
$this->logger->notice('login failed, refreshing access token');
$this->token->refresh();
public function handlePrivMsg(IRCMessage $msg) {
}
+ public function handleRoomstate(IRCMessage $msg) {
+ }
+
public function handleUserState(IRCMessage $msg) {
if (isset($msg->tags['user-id'])) {
$this->user_id = $msg->tags['user-id'];
$this->tagChannelRead($channel, $msg);
}
+ public function handleRoomstate(IRCMessage $msg) {
+ $channel = $this->getMessageChannel($msg);
+ if ($channel && $msg->hasTag('emote-only')) {
+ $oldEmote = $this->getNote($channel, 'emote_only');
+ $newEmote = !!intval($msg->getTag('emote-only'));
+ if ($oldEmote != $newEmote) {
+ $this->setNote($channel, 'emote_only', $newEmote);
+ }
+ }
+ }
+
public function handleWhisper(IRCMessage $msg) {
$text = $this->chatlib->generate($msg->getText());
$this->sendWhisper($msg->tags['user-id'], $text);
private function getNotes(Channel $channel) {
if (!isset($this->notes[$channel->id])) {
$this->notes[$channel->id] = [
+ 'emote_only' => false,
'last_read' => 0,
'last_special' => [],
'last_write' => time(),
}
private function randomChat(Channel $channel) {
- return $channel->queryChatlog()
- ->whereNotIn('classification', ['gg', 'gl', 'number', 'o7'])
- ->first();
+ $query = $channel->queryChatlog()
+ ->whereNotIn('classification', ['gg', 'gl', 'number', 'o7']);
+ if ($this->getNote($channel, 'emote_only', false)) {
+ $query->where('emote_only', '=', true);
+ }
+ return $query->first();
}
private function randomContextualNumber(Channel $channel) {
}
private function randomMsg(Channel $channel) {
- return $channel->queryChatlog()->first();
+ $query = $channel->queryChatlog();
+ if ($this->getNote($channel, 'emote_only', false)) {
+ $query->where('emote_only', '=', true);
+ }
+ return $query->first();
}
private function performAdlib(Channel $channel) {
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('chat_logs', function (Blueprint $table) {
+ $table->boolean('emote_only')->default(false);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('chat_logs', function (Blueprint $table) {
+ $table->dropColumn('emote_only');
+ });
+ }
+};