[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/boards/ - 8chan Boards

Find the hot board of your dreams

Catalog

8chan Bitcoin address: 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C
The next generation of Infinity is here (discussion) (contribute)
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, swf, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 5 per post.


/boards/ is for finding/advertising boards.
Use the stickies to leave a "permanent" link to a board, but don't post duplicates in the stickies. You can also make a new thread for advertising a board. If you know of a cool board that isn't here, feel free to post it even if you didn't create it. Rules

Also check out the dynamic boards list.

File: 1427653201079.png (12.48 KB, 167x150, 167:150, oh shit faggot.png)

 No.6563

Too lazy to login to your board/board you're moderating to check if there are any reports? Or perhaps you'd like some magic notification popping up in front of you if there are any reports, without having to login?

I made a thing (Linux only, but probably not difficult to adapt).

#!bin/sh

# Set script directory
path="/path/to/script"

# Login
wget –keep-session-cookies \
–save-cookies $path/cookies.txt \
–post-data 'username=<username>&password=<password>&login=Continue' \
https://8ch.net/mod.php \
–delete-after

# Get number of reports
get=$(wget –load-cookies $path/cookies.txt https://8ch.net/mod.php -q -O - | grep -Po '(?<=queue \().*(?=\))')

# Check number of reports, notify if there are some
if [ "$get" != 0 ]
then
zenity –width 150 –warning –timeout=30 –text="Reports: $get"

fi

rm $path/cookies.txt

exit 0


You can remove/change the "–timeout=30" part which closes the popup after 30 seconds if you like. Put the script wherever and change path to your liking. In crontab -e put in the following (runs it every 30 minutes, change if you like):
*/30 * * * *  export DISPLAY=:0.0 && sh /path/to/script/script.sh


And finally this is needed in .bash_profile or else zenity derps out:
[[ $DISPLAY ]] && xhost +localhost:$LOGNAME


Enjoy I guess. Nothing special really. Could probably be done better too.

 No.6567

I got bored again.

Change the first if-statement with this for even more expediency.

Not sure how to open with the session cookie so you can skip login though. That would have been even better.
  zenity –width=150 –question –title="Warning" –text="Reports: $get \
\n\n Deal with it now?" –window-icon="warning" –timeout=30

if [ "$?" = 0 ]
then
xdg-open https://8ch.net/mod.php?/reports

fi

 No.6568

>>6567
>Change the first if-statement with this
That is to say, replace the zenity line with that so that you have a nested if-statement.

 No.7560

yad is more efficient than zenity


 No.8026

>>7560

I can't into that. I could probably make this into a Java program so this trickery with Zenity and CRON wouldn't be a problem, but it would still depend on wget (and maybe also grep if I'm lazy).

Anyway, here's a small update.

#!bin/sh

# Set vars.
path="/path/to/scriptfolder"
un="WingedFaggot"
pw="123456"

# Log in.
wget –keep-session-cookies \
–save-cookies $path/cookies.txt \
–post-data "username=$un&password=$pw&login=Continue" \
https://8ch.net/mod.php \
–delete-after

# Get number of reports.
get=$(wget –load-cookies $path/cookies.txt https://8ch.net/mod.php \
-q -O - | grep -Po '(?<=queue \().*(?=\)</a>)')

# Check number of reports, then take action/inaction.
if [ "$get" != 0 -a "$get" -eq "$get" ]
then
zenity –width=150 –question –title="Warning" –text="Reports: $get \
\n\n Deal with it now?" –window-icon="warning" –timeout=30

if [ "$?" = 0 ]
then
xdg-open https://8ch.net/mod.php?/reports
fi

# Script is fucked.
else
if [ "$get" != 0 ]
then
zenity –width=150 zenity –error –text "Checkreports script failed! " \
–timeout=30
fi

fi

rm $path/cookies.txt

exit 0


 No.8038

>>8026

I wonder if we could perhaps use the ideas from this script to automate some sort of mod bot to do anything we wanted


 No.9377

>>6563

on most systems you can create native notifications from bash using the notify-send command.

try it. some people might prefer actual notifications over zenity's windows




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]