Skip to content

Commit

Permalink
plugin autoreply small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gojigeje committed Mar 11, 2015
1 parent e228726 commit 668bf16
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 7 deletions.
29 changes: 23 additions & 6 deletions plugin/autoreply-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ autoreply_command() {
command_pong
elif [[ "$comm_tipe" == "!adsl" ]]; then
command_adsl
elif [[ "$comm_tipe" == "!kissanime" ]]; then
command_kissanime
else
respon="1"
fi
Expand All @@ -80,7 +82,7 @@ autoreply_command() {

command_say() {
if [[ "$isngadimin" == "1" ]]; then
echo "[autoreply] [twit] : admin $comm_user nyuruh kita bilang $comm_isi"
echo "[autoreply] admin $comm_user nyuruh kita bilang $comm_isi"
twit -s "$comm_isi"
else
# echo "[twit] : $comm_user nyuruh2 !say"
Expand Down Expand Up @@ -130,7 +132,7 @@ command_unfollow() {
}

command_status() {
echo "[autoreply] [twit] : admin $comm_user nanyain status kita"
echo "[autoreply] admin $comm_user nanyain status kita"

statusnya_array=(
"bokek akut"
Expand Down Expand Up @@ -161,7 +163,7 @@ command_status() {

command_info() {
if [[ "$isngadimin" == "1" ]]; then
echo "[autoreply] [twit] : admin $comm_user minta info"
echo "[autoreply] admin $comm_user minta info"

uname -a > "temp/command.info.twit1"
up=$(uptime)
Expand Down Expand Up @@ -198,7 +200,7 @@ command_info() {

command_ipgue() {
if [[ "$isngadimin" == "1" ]]; then
echo "[autoreply] [twit] : admin $comm_user minta info IP Publik"
echo "[autoreply] admin $comm_user minta info IP Publik"

twit -r "$twit_id" -s "Siap bos $comm_user! Sedang mengambil IP Publik, habis ini ane DM bos.. :)"

Expand Down Expand Up @@ -228,12 +230,12 @@ command_pong() {

command_adsl() {
if [[ "$isngadimin" == "1" ]]; then
echo "[autoreply] [twit] : admin $comm_user minta info adsl"
echo "[autoreply] admin $comm_user minta info adsl"

twit -r "$twit_id" -s "Siap bos $comm_user! Sedang mengambil info ADSL dari modem, habis ini ane twit.. :)"

# masukin twit id ke database, lakukan sekarang karena plugin adsl ada exit
echo "$twit_id" >> "temp/reply_replied"
echo "$twit_id $comm_user" >> "temp/reply_replied"

# memanggil plugin lain
twit_adsl_main
Expand All @@ -244,3 +246,18 @@ command_adsl() {
udahdibalas="1"
fi
}

command_kissanime() {
if [[ "$isngadimin" == "1" ]]; then
echo "[autoreply] admin $comm_user nyuruh liat kissanime"
twit -r "$twit_id" -s "Siap bos $comm_user! Sedang mengambil info $comm_isi dari kissanime, habis ini ane twit.. :)"

echo "$twit_id $comm_user" >> "temp/reply_replied"
kissanime "$comm_isi"

else
# echo "[twit] : $comm_user nyuruh2 !say"
twit -r "$twit_id" -s "oi oi.. $comm_user emangnya elu siapa nyruh2 gue gitu..??"
udahdibalas="1"
fi
}
77 changes: 77 additions & 0 deletions plugin/autoreply-kissanime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
#

kissanime() {
# link t.co
tco="$1"
kissurl=$(curl -sI "$tco" | grep -i location | tr -d '\r' | cut -d " " -f2)

echo "[autoreply] [kissanime] link t.co : $tco"
echo "[autoreply] [kissanime] link kissanime : $kissurl"

cLink=$(echo $kissurl | sed 's/http:\/\///g' | sed 's/\/$//g')
cSitus=$(echo $cLink | cut -d "/" -f1)
cAnime=$(echo $cLink | cut -d "/" -f2)
cJudul=$(echo $cLink | cut -d "/" -f3)
cEpisode=$(echo $cLink | cut -d "/" -f4)
# echo "kissurl: $kissurl ~ cLink: $cLink ~ cSitus: $cSitus ~ cAnime: $cAnime ~ cJudul: $cJudul ~ cEpisode: $cEpisode"

target="http://proksi.ml/kissanime.com/Anime/$cJudul"
echo "[autoreply] [kissanime] link proksi : $target"

if [[ "$cSitus" = "kissanime.com" || "$cSitus" = "www.kissanime.com" ]]; then
kissanime_curlpage
else
twit -r "$twit_id" -s "Maaf bos $comm_user, Kayaknya link $tco salah deh :( ~ Itu beneran link kissanime?"
exit 1
fi
}

kissanime_curlpage() {
echo "[autoreply] [kissanime] download page.."
curl -A "$ua" -s "$target" > "temp/kissanime.temp"

judulAnime=$(cat "temp/kissanime.temp" | grep bigChar | head -n1 | sed 's/<[^>]\+>/ /g' | sed "s/[ \t]*//$g" | sed 's/ $//g')
jumlLink=$(awk '/<table\>/{a=1;next}/<\/table\>/{a=0}a' "temp/kissanime.temp" | grep "<a *.href=" | wc -l)
status=$(cat "temp/kissanime.temp" | grep "Status:" | cut -d ";" -f2 | sed 's|<[^>]*>||g')
lastEps=$(awk '/<table\>/{a=1;next}/<\/table\>/{a=0}a' "temp/kissanime.temp" | grep "<a href=" | head -n1 | grep -o -E "title=[\"'](.*)[\"']" | cut -d "\"" -f2 | sed 's/.*Episode //g;s/[^0-9]//g;s/^0*//')
thumbnail=$(cat "temp/kissanime.temp" | grep image_src | grep -o -E "href=[\"'](.*)[\"']" | cut -d "\"" -f2 | sed -s 's/^/http:\/\/proksi.ml/g')

# echo "judulAnime: $judulAnime"
# echo "jumlLink: $jumlLink"
# echo "status: $status"
# echo "lastEps: $lastEps"
# echo "thumbnail: $thumbnail"

echo "[kissanime] cc $comm_user" > "temp/kissanime.twit"
echo "$judulAnime" >> "temp/kissanime.twit"
echo "$status, $jumlLink files" >> "temp/kissanime.twit"
echo "Terbaru: $lastEps" >> "temp/kissanime.twit"
# cat temp/kissanime.twit

echo -n "[autoreply] [kissanime] download thumbnail.."
curl -s "$thumbnail" -o "temp/kissanime.$cJudul.jpg"

if [[ -f "temp/kissanime.$cJudul.jpg" ]]; then
echo "ok"

if [[ "$judulAnime" == "" || "$jumlLink" == "" || "$status" == "" || "$lastEps" == "" || "$thumbnail" == "" ]]; then
echo "[autoreply] [kissanime] ada data yang kosong.. exit :("

twit -r "$twit_id" -s "Maap bos $comm_user, kyaknya ada data yg kelewat deh pas ane cari info $tco tadi, duh.. coba lagi ya bos :("
exit
fi

echo "[autoreply] [twit]"
twit -s "`cat temp/kissanime.twit`" -i "temp/kissanime.$cJudul.jpg"

# cleanup
rm temp/kissanime.*
else
echo "gagal"
echo "[autoreply] [kissanime] exit :("
exit
fi

exit
}
2 changes: 1 addition & 1 deletion plugin/autoreply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ twit_autoreply_main() {
fi
fi
# masukin twit_id ke database
echo "$twit_id" >> "temp/reply_replied"
echo "$twit_id $twit_user" >> "temp/reply_replied"

sleep 3
fi
Expand Down

0 comments on commit 668bf16

Please sign in to comment.