Now, when a line begins with a punctuation, it calls the specified module.
This commit is contained in:
parent
d9b180deb3
commit
508e3da1cf
20
bot.sh
20
bot.sh
@ -6,9 +6,9 @@ input=".botinput"
|
|||||||
|
|
||||||
close_bot()
|
close_bot()
|
||||||
{
|
{
|
||||||
echo -en "QUIT :$quitMessage\r\n" >> "$input"
|
echo -en "QUIT :$quitMessage\r\n" >> "$input"
|
||||||
rm "$input"
|
rm "$input"
|
||||||
sleep 10
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
trap close_bot EXIT $?
|
trap close_bot EXIT $?
|
||||||
@ -70,14 +70,16 @@ do
|
|||||||
if [[ "$res" =~ .*http://|https://|www\..* ]]; then
|
if [[ "$res" =~ .*http://|https://|www\..* ]]; then
|
||||||
./triggers/link/link.sh "$who" "$from" "$res"
|
./triggers/link/link.sh "$who" "$from" "$res"
|
||||||
# Although this calls modules, it triggers on text other than the bot's nick
|
# Although this calls modules, it triggers on text other than the bot's nick
|
||||||
elif [[ "$res" =~ *PRIVMSG\ \#${from#*#}\ :$triggers* ]]; then
|
elif [[ "$res" =~ ^.*PRIVMSG.*:[[:punct:]].* ]]; then
|
||||||
com"${res#*:$triggers}"
|
com="${res#*:[[:punct:]]}"
|
||||||
com"${com//# /}"
|
com="${com//# /}"
|
||||||
if [ -z "$(ls modules/ | grep -i -- "${com%* }")" ] || [ -z "$com" ]; then
|
will="${com#* }"
|
||||||
./modules/help/help.sh $who $from
|
com="${com%% *}"
|
||||||
|
if [ -z "$(ls modules/ | grep -i -- "$com")" ] || [ -z "$com" ]; then
|
||||||
|
./modules/help/help.sh "$who" "$from"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
./modules/${com% *}/${com% *}.sh $who $from "${com#* }"
|
./modules/${com% *}/${com% *}.sh "$who" "$from" "$will"
|
||||||
fi
|
fi
|
||||||
# "#" would mean it's a channel
|
# "#" would mean it's a channel
|
||||||
if [ "$(echo "$from" | grep '#')" ]; then
|
if [ "$(echo "$from" | grep '#')" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user