summaryrefslogtreecommitdiffstats
path: root/omegle.sh
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-08-25 14:36:11 +0200
committerFlorian Bruhin <git@the-compiler.org>2013-08-25 14:36:11 +0200
commitfdf4689c8cfce02256385f9e15373f8ae74c9ee6 (patch)
treec6ecf0402c95f11b7fa7f30f15f7874e1d910279 /omegle.sh
downloadomegle_eliza-master.tar.gz
omegle_eliza-master.zip
Initial commitHEADmaster
Diffstat (limited to 'omegle.sh')
-rwxr-xr-xomegle.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/omegle.sh b/omegle.sh
new file mode 100755
index 0000000..94f146b
--- /dev/null
+++ b/omegle.sh
@@ -0,0 +1,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