penelope

created pr with 114.1 on 2026-02-25T00:32:19Z · by ba3031e9
added 114.2 on 2026-02-25T00:34:17Z · by ba3031e9
1: 3c7cbc2 = 1: 3c7cbc2 convert to environment variables
-: ------- > 2: 5798fe8 change port env name to avoid collision
cmds
checkout latest patchset:
ssh pr.pico.sh print 114 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 114.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 114

Patchset 114.2 on 2026-02-25T00:34:17Z · commit 5798fe8

change port env name to avoid collision
Melanie Kat 2026-02-25T00:33:44Z
Semantic diff summary
0 added, 0 modified, 0 signature changed, 0 removed across 0 analyzed files (1 file skipped: unsupported file type)
+50 -52 bot.php #
......@@ -9,7 +9,7 @@ $nickname = $_ENV["NICKNAME"];
99 $hostname = $_ENV["HOSTNAME"];
1010 $password = $_ENV["PASSWORD"];
1111 $server = $_ENV["SERVER"];
12-$port = $_ENV["PORT"];
12+$port = $_ENV["IRCPORT"];
1313
1414 // In order to update the bot's code while it's connected to IRC, we need a separate "functions" script.
1515 // This script will receive a stream of the IRC activity, and then it'll "do stuff" and send the response
......@@ -26,27 +26,27 @@ set_time_limit(0);
2626
2727 // Now we'll set up our connection
2828 $context = stream_context_create([
29- 'ssl' => [
30- 'verify_peer' => true,
31- 'verify_peer_name' => true,
32- 'allow_self_signed' => false,
33- 'SNI_enabled' => true,
34- 'peer_name' => $server,
35- ],
29+ 'ssl' => [
30+ 'verify_peer' => true,
31+ 'verify_peer_name' => true,
32+ 'allow_self_signed' => false,
33+ 'SNI_enabled' => true,
34+ 'peer_name' => $server,
35+ ],
3636 ]);
3737
3838 // And actually connect
3939 $socket = stream_socket_client(
40- "tls://{$server}:{$port}",
41- $errno,
42- $errstr,
43- 30,
44- STREAM_CLIENT_CONNECT,
45- $context
40+ "tls://{$server}:{$port}",
41+ $errno,
42+ $errstr,
43+ 30,
44+ STREAM_CLIENT_CONNECT,
45+ $context
4646 );
4747
48-if(!$socket) {
49- die("Connection failed: $errstr ($errno)\n");
48+if (! $socket) {
49+ die("Connection failed: $errstr ($errno)\n");
5050 }
5151
5252 // If our code is still running at this point, we're connected to the server!
......@@ -58,47 +58,45 @@ fputs($socket, "NICK " . $nickname . "\n");
5858 fputs($socket, "USER " . $nickname . " 0 * :$nickname@$hostname\n");
5959
6060 // Send avatar metadata? does this even work? lol
61-if($avatar_url) {
62- fputs($socket, "METADATA * SET avatar $avatar_url\n");
61+if ($avatar_url) {
62+ fputs($socket, "METADATA * SET avatar $avatar_url\n");
6363 }
6464
65-
6665 // Loopy loop forever and ever and ever
67-while(1) {
68- while ($data = fgets($socket, 512)) {
69- echo $data;
70- flush();
71-
72- // Take the line of data that we've received and snap it into separate pieces wherever there's a space
73- $pieces = explode(' ', $data);
74-
75- // At this point, $pieces[0] will contain the sender, and $pieces[1] will contain the command that was sent
76-
77- // Send a PONG back to the server whenever we receive a PING
78- if($pieces[0] == "PING") {
79- fputs($socket, "PONG " . $pieces[1] . "\n");
80- }
81-
82- // Otherwise, we're going to send everything to our separate functions script for handling
83- else {
84-
85- // Execute the functions script, passing the $data to it as an argument
86- $response = shell_exec($functions_script_command.' '.escapeshellarg($data));
87-
88- // Since we're receiving JSON in response, we'll decode that
89- $response = json_decode($response);
90-
91- // Process responses
92- if(isset($response->response)) {
93- if(is_countable($response->response)) {
94- foreach($response->response as $response_item) {
95- fputs($socket, $response_item."\r\n");
96- }
66+while (1) {
67+ while ($data = fgets($socket, 512)) {
68+ echo $data;
69+ flush();
70+
71+ // Take the line of data that we've received and snap it into separate pieces wherever there's a space
72+ $pieces = explode(' ', $data);
73+
74+ // At this point, $pieces[0] will contain the sender, and $pieces[1] will contain the command that was sent
75+
76+ // Send a PONG back to the server whenever we receive a PING
77+ if ($pieces[0] == "PING") {
78+ fputs($socket, "PONG " . $pieces[1] . "\n");
9779 }
80+
81+ // Otherwise, we're going to send everything to our separate functions script for handling
9882 else {
99- fputs($socket, $response->response."\r\n");
83+
84+ // Execute the functions script, passing the $data to it as an argument
85+ $response = shell_exec($functions_script_command . ' ' . escapeshellarg($data));
86+
87+ // Since we're receiving JSON in response, we'll decode that
88+ $response = json_decode($response);
89+
90+ // Process responses
91+ if (isset($response->response)) {
92+ if (is_countable($response->response)) {
93+ foreach ($response->response as $response_item) {
94+ fputs($socket, $response_item . "\r\n");
95+ }
96+ } else {
97+ fputs($socket, $response->response . "\r\n");
98+ }
99+ }
100100 }
101- }
102101 }
103- }
104102 }
Back to top