Skip to content

Commit a6a891b

Browse files
committed
Added relay module upon request by Sakera.
1 parent 042b843 commit a6a891b

File tree

6 files changed

+87
-4
lines changed

6 files changed

+87
-4
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4-12
1+
0.4-13

bin/relay

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
iinput=$(echo "$2" | sed -e 's/.//')
3+
iinput="i$iinput"
4+
while true; do
5+
line=$(cat "$1.relay")
6+
7+
lines=$(wc -l "$1.relay" | awk '{print $1}')
8+
while read line; do
9+
x=$((x+1))
10+
input=$(echo "$line" | awk '{print $1}')
11+
if [ "$input" != "$iinput" ] && [ "$line" ]; then
12+
if [ "$(echo "$line" | awk '{print $1}')" ]; then
13+
cat "$1.relay" | sed -e "/$line/d" > "$1.relay_"; mv "$1.relay_" "$1.relay"
14+
echo "PRIVMSG #bashirc :${line#* }" >> "$iinput"
15+
#mv "$1.relay_" "$1.relay"
16+
sleep 1
17+
fi
18+
fi
19+
done < "$1.relay"
20+
21+
22+
23+
done

contrib/relay.module

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
#Part of relay module for bashIRC
3+
# © ttwj 2010
4+
if [ "$(type)" = "PRIVMSG" ] && [ "$(dest chan)" ] && [ -e "$(dest chan).relay" ]; then
5+
echo "$raw_input <$(nick)> $(text)" >> "$(dest chan).relay"
6+
fi

modules/infobot.module

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
if [ "$(type)" = "PRIVMSG" ] && [ "$(dest chan)" ]; then
3+
if [ "$(text | awk '{print $1}')" = "what" ] && [ "$(text | awk '{print $2}')" = "is" ]; then
4+
line=$(cat stuff | grep -i "info:$(text | awk '{print $3}' | sed -e 's/?//')")
5+
if [ ! "$line" ]; then
6+
notice $(nick) "Sorry, no definition for $(text | awk '{print $3}') exists."
7+
else
8+
echo "$line" > /tmp/shit
9+
x=
10+
while read shit; do
11+
msg $(dest) "${shit#* }"
12+
done < /tmp/shit
13+
fi
14+
elif [ "$(text | awk '{print $1}')" = "what" ] && [ "$(text | awk '{print $2}')" = "are" ]; then
15+
line=$(cat stuff | grep -i "info:$(text | awk '{print $3}' | sed -e 's/?//')")
16+
if [ ! "$line" ]; then
17+
notice $(nick) "Sorry, no definition for $(text | awk '{print $3}') exists."
18+
else
19+
echo "$line" > /tmp/shit
20+
while read shit; do
21+
msg $(dest) "${shit#* }"
22+
done < /tmp/shit
23+
fi
24+
elif [ "$(text | awk '{print $2}')" = "is" ]; then
25+
26+
stuff=$(sed -e "s/info:$(text | awk '{print $2}') \(.*\)/info:$(text | awk '{print $2}') $(text)/" "stuff")
27+
if [ ! "$(cat stuff | grep -i "info:$(text | awk '{print $1}')")" ]; then
28+
echo "info:$(text | awk '{print $1}') $(text)" >> stuff
29+
else
30+
stuff=$(sed -e "s/info:$(text | awk '{print $2}') \(.*\)/info:$(text | awk '{print $2}') $(text)/" "stuff" > .stuff)
31+
mv .stuff stuff
32+
fi
33+
notice $(nick) "Added definition"
34+
elif [ "$(text | awk '{print $2}')" = "are" ]; then
35+
36+
stuff=$(sed -e "s/info:$(text | awk '{print $2}') \(.*\)/info:$(text | awk '{print $2}') $(text)/" "stuff")
37+
if [ ! "$(cat stuff | grep -i "info:$(text | awk '{print $1}')")" ]; then
38+
echo "info:$(text | awk '{print $1}') $(text)" >> stuff
39+
else
40+
stuff=$(sed -e "s/info:$(text | awk '{print $2}') \(.*\)/info:$(text | awk '{print $2}') $(text)/" "stuff" > .stuff)
41+
mv .stuff stuff
42+
fi
43+
notice $(nick) "Added definition"
44+
fi
45+
fi

modules/sample.module

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ owner="Halon"
44
$(help.hook "$(fantasy.char)lmg <stuff> -- Googles stuff for you") > /dev/null
55
$(help.hook "$(fantasy.char)shorten <url> -- Shortens URL for you :)") > /dev/null
66
$(help.hook "$(fantasy.char)say <some stuff> -- Say that some stuff for you :p") > /dev/null
7-
function say() {
8-
msg $(dest) "${@}"
9-
}
7+
#function say() {
8+
# msg $(dest) "${@}"
9+
#}
1010
function shorten() {
1111
#Using fantasy omits the original fantasy word
1212
shortened=$(curl -s "http://is.gd/api.php?longurl=$1")

relay-module

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The relay module is currently in beta stage.
2+
To use:
3+
1. Move relay.module from contrib/ to modules/
4+
2. In bin/, ./relay "<channel>" "<corresponding input file>"
5+
6+
* And no, I will not tell you what does corresponding input file means, figure it out your own.
7+
8+
- More documentation to come when it's fully ready :)
9+

0 commit comments

Comments
 (0)