annna-message-radio - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
annna-message-radio (2267B)
---
1 #!/bin/sh -e
2
3 [ "$IRC_CMD_USER" = "${IRC_USER}" ] && exit
4
5 case "${IRC_PRIVMSG_TEXT}" in
6 "${IRC_USER}, next"*) /usr/bin/mpc -q next; exit;;
7 "${IRC_USER}, prev"*) /usr/bin/mpc -q prev; exit;;
8 "${IRC_USER}, shuffle"*) /usr/bin/mpc -q shuffle; exit;;
9 "${IRC_USER}, random radio"*) /home/annna/bin/modules/radio/radio-random-channel-cronjob.sh; exit;;
10 "${IRC_USER}, random mode"*) /usr/bin/mpc -q random; exit;;
11 "${IRC_USER}, single mode"*) /usr/bin/mpc -q single; exit;;
12 "${IRC_USER}, consume mode"*) /usr/bin/mpc -q consume; exit;;
13 "${IRC_USER}, rescan"*) /usr/bin/mpc -q rescan; exit;;
14 "${IRC_USER}, how many people listen to the radio"*) annna-say "${IRC_CMD_USER}, $(/br/bin/bitreich-radio-listener-count)"; exit;;
15 "${IRC_USER}, playlist"*) annna-say "${IRC_CMD_USER}, $(mpc playlist | wc -l)"; exit;;
16 "${IRC_USER}, what is playing"*)
17 currentsong="$(mpc current 2>/dev/null)"
18 [ -n "${currentsong}" ] && annna-say "Now playing: ${currentsong}"
19 exit;;
20 "${IRC_USER}, radio play "*)
21 url="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 25- | sed 's,\t, ,g')"
22 {
23 ytdl-mpd -a -m -q "$url"
24 annna-say "Your download ${url} is done."
25 } &
26 exit;;
27 "${IRC_USER}, radio say "*)
28 word="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" | cut -c 25- | sed 's,\t, ,g')"
29 {
30 printf "%s\n" "${word}" | bitreich-radio-speak
31 annna-say "The speech is done."
32 } &
33 exit;;
34 "${IRC_USER}, stop speaking on radio"*)
35 if pkill -f bitreich-radio-speak >/dev/null 2>&1;
36 then
37 annna-say "${IRC_CMD_USER}, I stopped speaking."
38 else
39 annna-say "${IRC_CMD_USER}, sorry, no instances found."
40 fi
41 exit;;
42 "${IRC_USER}, radio status"*)
43 mpc_status="$(/usr/bin/mpc status "%state%")"
44 [ -z "$mpc_status" ] && mpc_status="gone"
45 annna-say "The radio is ${mpc_status}."
46 exit;;
47 "${IRC_USER}, like"*|"${IRC_USER}, unlike"*)
48 # TODO: Make sticker db work.
49 currenturi="$(/usr/bin/mpc -f "%file%" current)"
50 if [ -n "${currenturi}" ];
51 then
52 likes="$(/usr/bin/mpc sticker "${currenturi}" get likes)"
53 case "${IRC_PRIVMSG_TEXT}" in
54 "${IRC_USER}, like"*) newlikes="$(( ${likes} + 1 ))";;
55 "${IRC_USER}, unlike"*) newlikes="$(( ${likes} - 1 ))";;
56 esac
57 /usr/bin/mpc -q sticker "${currenturi}" set likes "${newlikes}"
58 annna-say "${currenturi} = ${likes} <3"
59 fi;;
60 esac
61
62 annna-message-common
63