added rps module, fixed minor bugs, removed the redundant test.sh
This commit is contained in:
parent
2b8141c224
commit
19181cdfa9
3
bot.sh
3
bot.sh
@ -26,14 +26,13 @@ do
|
|||||||
then
|
then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "PRIVMSG #$channel :Welcome $who, have some op :)" >> $config
|
|
||||||
echo "MODE #$channel +o $who" >> $config
|
echo "MODE #$channel +o $who" >> $config
|
||||||
;;
|
;;
|
||||||
# run when a message is seen
|
# run when a message is seen
|
||||||
*PRIVMSG*)
|
*PRIVMSG*)
|
||||||
echo "$res"
|
echo "$res"
|
||||||
who=$(echo "$res" | sed -r "s/:(.*)\!.*@.*/\1/")
|
who=$(echo "$res" | sed -r "s/:(.*)\!.*@.*/\1/")
|
||||||
from=$(echo "$res" | sed -r "s/.*PRIVMSG ([#]?[a-zA-Z]*) :.*/\1/")
|
from=$(echo "$res" | sed -r "s/.*PRIVMSG ([#]?([a-zA-Z]|\-)*) :.*/\1/")
|
||||||
# "#" would mean it's a channel
|
# "#" would mean it's a channel
|
||||||
if [ "$(echo "$from" | grep '#')" ]
|
if [ "$(echo "$from" | grep '#')" ]
|
||||||
then
|
then
|
||||||
|
1
modules/args.sh
Executable file
1
modules/args.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
echo "PRIVMSG $2 :$1: $@"
|
@ -1,3 +1,3 @@
|
|||||||
echo "PRIVMSG $2 :$1: The available modules I have are:"
|
echo "PRIVMSG $2 :$1: The available modules I have are:"
|
||||||
output=$(ls modules/ | sed "s/.sh//")
|
output=$(find modules/ -maxdepth 1 -type f -not -name ".*" -printf "%f\n" | sed "s/.sh//")
|
||||||
echo "PRIVMSG $2 :$1: "$output
|
echo "PRIVMSG $2 :$1: "$output
|
||||||
|
32
modules/rps.sh
Executable file
32
modules/rps.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 0 - rock
|
||||||
|
# 1 - paper
|
||||||
|
# 2 - scissor
|
||||||
|
|
||||||
|
m_choice=$(($RANDOM%3))
|
||||||
|
o_choice=$(echo $4 | sed -r "s/^[rR].*/0/" | sed -r "s/^[pP].*/1/" | sed -r "s/^[sS].*/2/")
|
||||||
|
|
||||||
|
#convert my random to either r/p/s
|
||||||
|
case "$m_choice" in
|
||||||
|
0)
|
||||||
|
mr_choice="rock"
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
mr_choice="paper"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
mr_choice="scissor"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$m_choice" == "$o_choice" ]
|
||||||
|
then
|
||||||
|
outcome="tie"
|
||||||
|
elif [ "$((($m_choice+1)%3))" == "$o_choice" ]
|
||||||
|
then
|
||||||
|
outcome="lose"
|
||||||
|
else
|
||||||
|
outcome="win"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "PRIVMSG $2 :$1: $4 VS $mr_choice | I $outcome!"
|
@ -1 +0,0 @@
|
|||||||
echo "PRIVMSG $2 :$1: The test was successful"
|
|
Loading…
x
Reference in New Issue
Block a user