Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Issues (412)

src/tools/irc/notice.php (1 issue)

Severity
1
<?php declare(strict_types=1);
2
3
use Smr\Database;
4
use Smr\Irc\CallbackEvent;
5
6
/**
7
 * @param resource $fp
8
 */
9
function notice_nickserv_registered_user($fp, string $rdata): bool {
0 ignored issues
show
The parameter $fp is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

9
function notice_nickserv_registered_user(/** @scrutinizer ignore-unused */ $fp, string $rdata): bool {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
10
11
	// :[email protected] NOTICE Caretaker
12
	if (preg_match('/^:[email protected] NOTICE ' . IRC_BOT_NICK . ' :([^ ]+) is ([^.]+)\s$/i', $rdata, $msg)) {
13
14
		$nick = $msg[1];
15
		$registeredNick = $msg[2];
16
17
		echo_r('[NOTICE_NICKSERV_REGISTERED_NICK] ' . $nick . ' is ' . $registeredNick);
18
19
		$db = Database::getInstance();
20
21
		$dbResult = $db->read('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick));
22
		foreach ($dbResult->records() as $dbRecord) {
23
			$seen_id = $dbRecord->getInt('seen_id');
24
25
			$db->write('UPDATE irc_seen SET
26
						registered_nick = ' . $db->escapeString($registeredNick) . '
27
						WHERE seen_id = ' . $seen_id);
28
		}
29
30
		foreach (CallbackEvent::getAll() as $event) {
31
32
			// is that a callback for our nick?
33
			if ($event->type == 'NICKSERV_INFO' && $event->nick == $nick) {
34
				CallbackEvent::remove($event);
35
				($event->callback)();
36
			}
37
38
		}
39
40
		return true;
41
	}
42
43
	return false;
44
}
45
46
/**
47
 * @param resource $fp
48
 */
49
function notice_nickserv_unknown_user($fp, string $rdata): bool {
50
51
	// :[email protected] NOTICE Caretaker :Nickname Slevin isn't registered.
52
	if (preg_match('/^:[email protected] NOTICE ' . IRC_BOT_NICK . ' :Nickname .(.*). isn\'t registered\.\s$/i', $rdata, $msg)) {
53
54
		$nick = $msg[1];
55
56
		echo_r('[NOTICE_NICKSERV_UNKNOWN_NICK] ' . $nick);
57
58
		foreach (CallbackEvent::getAll() as $event) {
59
60
			// is that a callback for our nick?
61
			if ($event->type == 'NICKSERV_INFO' && $event->nick == $nick) {
62
63
				CallbackEvent::remove($event);
64
65
				if ($event->validate) {
66
					fwrite($fp, 'PRIVMSG ' . $event->channel . ' :' . $nick . ', you are not using a registered nick. Please identify with NICKSERV and try the last command again.' . EOL);
67
				}
68
69
			}
70
71
		}
72
		return true;
73
74
	}
75
76
	return false;
77
}
78