summaryrefslogtreecommitdiffstats
path: root/omegle.sh
blob: 94f146bda1dfb846840a7aa4f77dcf66e9a4ad85 (plain)
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
#!/bin/bash
>pidfile
trap "exit 0" USR1
trap 'kill $(<pidfile) 2>/dev/null; exit 0' INT TERM
oldifs="$IFS"
send() {
        message=$(sed -e 's/\:/%3a/g;s/\//%2f/g;s/\?/%3f/g;s/\&/%3d/g;s/\,/%2c/g;s/\[/%5b/g;s/\]/%5d/g;s/ /+/g;s/"/%22/g' <<< "$@")
        out=$(curl -d "id=$id&msg=$message" omegle.com/send 2>/dev/null)
	[[ "$out" == fail ]] && echo "[E] error while sending!"
}

echo "[I] Omegle-Bot by The-Compiler"

id=$(curl -d '' omegle.com/start 2>/dev/null)
echo "[D] got an id"
if grep -q '^"[a-zA-Z0-9_-]*"$' <<< "$id"; then
		id="${id//\"/}"
else
		echo "[E] Invalid ID: $id"
fi

while [[ "$disconnect" != 1 ]]; do
	events=$(curl -d "id=$id" omegle.com/events 2>/dev/null)
	echo "events_raw: $events" > debug
	case "$events" in
		"["*"]")
			events=$(sed 's/...//;s/...$//;s/"\], \["/\n/g;s/", "/=/g' <<< "$events")
			echo "events_afterSed: $events" > debug
			IFS=$'\n'
			for event in $events; do
				case "$event" in
					connected|typing|stoppedTyping|waiting) echo "[I] $event" ;;
					gotMessage*)
						message=$(cut -d '=' -f 2- <<< "$event" | sed 's/\\"/"/g')
						echo "[M] $message"
						;;
					strangerDisconnected) echo "[I] strangerDisconnected"; disconnect=1 ;;
					*) echo "[E] unknown status $events [in]" | tee -a debug ;;
				esac
			done
			;;
		null) echo "[I] strangerDisconnected"; echo "[E] null"; disconnect=1 ;; 
		"") ;;
		*) echo "[E] unknown status $events" ;;
	esac
done && kill -USR1 $$ &
echo "$!" > pidfile

while read line; do
	send "$line"
done

kill $(<pidfile)
exit 0