Skip to content

Commit b74b550

Browse files
committed
yeet
1 parent 93f5ec5 commit b74b550

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

hotreload

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# lmao dont judge me it works for me
44

55
while true; do
6-
tmux send-keys -t "%137" '\./server |& logfilter' Enter
6+
tmux send-keys -t "%$1" '\./server |& logfilter' Enter
77
sleep 0.1
88
inotifywait -qq "server" -e MODIFY -e MOVE_SELF
9-
tmux send-keys -t "%137" C-c
9+
tmux send-keys -t "%$1" C-c
1010
echo "reloading..."
1111
done

server

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ if [[ -z "$IRC_CONN_HANDLER" ]]; then
180180
query 'CREATE TABLE IF NOT EXISTS channels
181181
(
182182
id INTEGER PRIMARY KEY AUTOINCREMENT,
183-
name varchar(201) NOT NULL UNIQUE
183+
name varchar(201) NOT NULL UNIQUE,
184+
topic varchar(500)
184185
);'
185186

186187
query 'INSERT INTO channels(name) VALUES("#test");'
@@ -291,6 +292,28 @@ else
291292
fi
292293
printf "%s\r\n" ":$NICK PRIVMSG $TARGET $MSG" | broadcast
293294
;;
295+
296+
TOPIC)
297+
# TODO
298+
CHANNEL="${arr[0]}"
299+
arr=("${arr[@]:1}")
300+
# TOPIC="$(query "SELECT topic FROM channels WHERE name = ?;" "$CHANNEL")"
301+
# reply TOPIC "$CHANNEL" "$TOPIC"
302+
;;
303+
LIST)
304+
while IFS=$'\t' read -r channel_id channel visible topic; do
305+
reply 322 "$NICK $channel $visible :$topic"
306+
done <<< "$(query "SELECT
307+
channels.id,
308+
channels.name,
309+
COUNT(membership.who) AS visible,
310+
channels.topic
311+
FROM channels
312+
LEFT JOIN membership
313+
ON membership.channel = channels.id
314+
GROUP BY channels.id, channels.name, channels.topic;")"
315+
reply 323 ":End of LIST"
316+
;;
294317
JOIN)
295318
if [[ "${arr[@]}" == "0" ]]; then
296319
debug "joins: $NICK did join 0"
@@ -304,15 +327,20 @@ else
304327
split "$KEYS" ','
305328
KEYS=("${arr[@]}")
306329
for CHANNEL in ${CHANNELS[@]}; do
307-
CHANNEL_ID="$(query "SELECT id FROM channels WHERE name = ?;" "$CHANNEL")"
330+
IFS=$'\t' read -r CHANNEL_ID TOPIC <<< "$(query "SELECT id, topic FROM channels WHERE name = ?;" "$CHANNEL")"
308331
if [[ -z "$CHANNEL_ID" ]]; then
309332
continue
310333
fi
311334
query "INSERT INTO membership(channel, who) VALUES(?, ?);" "$CHANNEL_ID" "$CONN_ID"
312335
debug "joins: $NICK joined $CHANNEL"
313336
SUBS["$CHANNEL"]=true
314337
printf "%s\r\n" ":$NICK!$USER@$IRC_SERVER_HOST JOIN :$CHANNEL" | broadcast
315-
reply 366 $NICK $CHANNEL :
338+
EVERYONE="$(query "SELECT conns.nick FROM membership LEFT JOIN conns
339+
ON conns.id = membership.who WHERE membership.channel = ?;" "$CHANNEL_ID")"
340+
EVERYONE="${EVERYONE//$'\n'/ }"
341+
reply 353 "$NICK" '=' "$CHANNEL" ":$EVERYONE"
342+
reply 366 "$NICK" "$CHANNEL" ':'
343+
reply 332 "$NICK" "$CHANNEL" ":$TOPIC"
316344
done
317345
fi
318346
;;
@@ -328,6 +356,7 @@ else
328356
CHANNELS=("${arr[@]}")
329357
split "$KEYS" ','
330358
KEYS=("${arr[@]}")
359+
query "DELETE FROM membership WHERE channel = ? AND who = ?;" "$CHANNEL_ID" "$CONN_ID"
331360

332361
for CHANNEL in ${CHANNELS[@]}; do
333362
unset SUBS["$CHANNEL"]

things.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
Implement nicknames properly
1+
TLS
2+
TOPICS
23

34
Commands:
4-
[ ] NICK command
5-
[ ] LIST command
5+
[x] NICK command
6+
[x] LIST command
67
[x] PART command
78
[x] QUIT command
9+
[ ] TOPIC command
810
[ ] MODE command
911
[ ] NAMES command
1012
[ ] WHOIS command

0 commit comments

Comments
 (0)