-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMsgHandler
More file actions
66 lines (54 loc) · 1.07 KB
/
MsgHandler
File metadata and controls
66 lines (54 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
## MsgHandler
# Callback on receving a PRIVMSG
irc_msg_callback()
{
echo "-Msg- ${1}/${2} ${3}";
# identify if msg sent in private or channel
local REPLYTO="";
case "$2" in
"$NICK" )
REPLYTO="${1}";
;;
*)
REPLYTO="${2}";
;;
esac
# commands
. Interpreter
irc_msg_interpret ${1} ${2} ${3} ${REPLYTO};
return;
}
irc_handle_message()
{
local FULLMSG="$@";
oldIFS="${IFS}";
IFS=":!${IFS}";
set $@;
local FROM=$2;
local TO=$5;
IFS="${oldIFS}";
set ${FULLMSG};
shift ; shift ; shift;
local MSG="$@";
IFS="${oldIFS}";
irc_msg_callback "${FROM}" "${TO}" "${MSG}";
return 0;
}
util_generate_gurr(){
local countU=$(( 1 + $(( $RANDOM % 5 ))));
local countR=$(( 2 + $(( $RANDOM % 3 ))));
local i=0;
local gurr="*g"
for (( i=0 ; $i<$countU ; i++ ))
do
gurr="${gurr}u";
done
i=0;
for (( i=0 ; $i<$countR ; i++ ))
do
gurr="${gurr}r";
done
gurr="${gurr}*"
echo ${gurr}
}