Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- htllMakeAuthReq() {
- #Load the cookie and make the request to the first arg past to this function
- req=$(curl -s -b $cookieFile $1)
- }
- htllLogin() {
- username='username'
- password='pasword'
- cookieFile='htll-cookie.txt'
- loginUrl="https://hightechlowlife.eu/board/login/login"
- #Login and get cookie silently
- loginReq=$(curl -s -c $cookieFile -d "login=$username&password=$password" $loginUrl)
- }
- getMessages() {
- #locating messages
- message=$(echo -e "$req" | grep "siropuChatMessage\">.*</span" | grep -ioP '">.*</span>')
- #Remove some of the info messages
- message=$(echo -e "$message" | grep -v "</a> is our newest member. Welcome!</span>")
- #Remove more of the info messages
- message=$(echo -e "$message" | grep -v "</a> has started a new thread called "<a href=")
- #Stepping to the message
- message=$(echo -e "$message" | cut -d">" -f2- | sed -E 's/<span .*?">//')
- #Get rid of span tags
- message=$(echo -e "$message" | sed 's/<\/span>//g' | sed s'/<span>//g')
- #Convert html apostraphe
- message=$(echo -e "$message" | sed "s/'/'/g")
- #Convert html qoute
- message=$(echo -e "$message" | sed 's/"/"/g')
- #Remove html around links
- message=$(echo -e "$message" | sed -E 's/<a href=.*?">//' | sed -E 's/<\/a>//')
- #Convert html greater than sign
- message=$(echo -e "$message" | sed 's/>/>/g')
- }
- getUsernames() {
- usernames=$(echo -e "$req" | grep -v "siropuChatBot" | grep -ioP "data-author=\".*?\">" | cut -d'"' -f2)
- }
- getShouty() {
- #Get current shoutbox
- htllMakeAuthReq $shout
- #parse for messages
- getMessages
- #parse for usernames
- getUsernames
- IFS=$'\n'
- line=1
- #print shouty
- for i in $(echo -e "$message"); do
- currentUser=$(echo -e "$usernames" | sed "$line"'!d')
- echo "$currentUser: $i"
- ((line++))
- done
- }
- #Login
- htllLogin
- #Get shouty
- shout="https://hightechlowlife.eu/board/chat/"
- while :; do
- latestShouty=$(getShouty)
- if [ -z "$oldShouty" ]; then
- echo -e "$latestShouty"
- fi
- if [ "$latestShouty" != "$oldShouty" ]; then
- if [ -n "$oldShouty" ]; then
- lastLineOfOldShouty=$(echo -e "$oldShouty" | tail -1)
- locationOfLastLineinNewShouty=$(echo -e "$latestShouty" | grep -n "$lastLineOfOldShouty" | cut -f1 -d:)
- newShouts=$(echo -e "$latestShouty" | sed '1,'"$locationOfLastLineinNewShouty"'d')
- echo -e "$newShouts"
- fi
- fi
- sleep 2
- oldShouty="$latestShouty"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement