Forum New Posts Notifier for NiftyHost
11-15-2010, 08:18 PM, (This post was last modified: 05-30-2011, 12:21 AM by RichardGv.)
#1
Smile  Forum New Posts Notifier for NiftyHost
I just wrote a script that notifies users of new posts on NiftyHost Forums. (Actually it's generic forum new post notifier that supports more than one forum.)

Current version: 0.01 Pre-Alpha 1 Developmental Preview 20110428 Nightly (I'm trying to break the world record of the longest software version number! :D )

Features:
It does what its name implies: Periodically send a request to forums and filter the response to find new posts. It then can display a message in the terminal, or execute a set of commands to show a notification window, or play some sound. (On POSIX systems, like Linux or BSD, it additionally provides shell-quoted strings for the commands.)
It shows unread posts in "View new posts" page (you may change it to "View daily posts", though), so sometimes it won't show all unread posts. If NiftyHost Forums has a plugin like View Unread Posts, after a small modification my script should be able to display all unread posts.

It's only tested on my Gentoo box. In fact I'm too lazy to reboot to Windows to test it. :) Theoretically, it should work on any platform where Python runs on, this includes Windows, Linux, BSD, Mac OS X, Darwin, Nintendo DS, Nokia N800, Nokia N810, Xbox, and PlayStation 2/3 (provided that there's an Internet connection). Use it at your own risk. It may burn your CPU and I won't offer you a compensation if that happens! :D

Changelog:
Nightly May 29th:
Nightly April 28th: http://www.niftyhost.us/support/thread-7...ml#pid8894
Nightly 20110408: http://www.niftyhost.us/support/thread-7...ml#pid8536
Nightly 20101118: http://www.niftyhost.us/support/thread-7...ml#pid6154
Nightly 20101117: http://www.niftyhost.us/support/thread-7...ml#pid6151
Nightly 20101116: http://www.niftyhost.us/support/thread-7...ml#pid6134
Nightly 20101115: Initial version.

Installation:
It's written with Python 3, and you will need a Python 3 interpreter to try it. For the latest version, Python 3.2 is required, and optionally, lxml.
For the unfortunate Windows users, it's required to install Python 3.2+ to use it. Most Linux users should have it pre-installed, yet not necessarily the latest version.
Installation wizard? No, we don't offer such a stupid thing. My principle of programming is to make programs as complicated as possible, so that no newbies will dare to try it and it saves my time of answering the stupid questions they could ask. :D Take a look at the configuration part to learn about how to configure it. (Without proper configuration it won't run at all!)

Configuration:
The content below is obsolete in favor of the new XML external configuration system. (They still work, though.) Please read this reply for a description of the new system. I plan to write a comprehensive README file later, after I learn asciidoc.
Following my tradition, this script is customizable in almost every aspect, and the options are all ill-documented. :D So there's a bunch of configuration options. You can change these options by editing the script file directly.
  1. Username and password. Fill them unless you have exported a cookies.txt in the correct location. They are on line 23 and 24:
    Code:
            niftyhost = dict(\
            enable = True, \
            username = '', \
            password = '', \
  2. 'enabled' option for each forum. The script supports a total of 6 forums (2 of them are effectively broken :) ), and if you don't have accounts on the other forums it supports, you should turn off their 'enabled' option. Basically just change "enabled = True" in all other places to "enabled = False" except the one right after "niftyhost = dict(\"
  3. Constant strlst['cmd']. Line 116. Commands executed when a new post is discovered. You can use it to, for example, play some sound or show a libnotify popup when a new post is found. You can specify different sets of commands for different operating systems, but unless you are using a POSIX system, just change the command list "default = ()". It's written in the format of a Python tuple. Examples:
    Code:
    # No command is the best command :D And this is the default value for Windows users.
    default = ()

    # Attention: If there's only a single string in the tuple, you need to add an extra comma after the string.
    default = (r'notify-send A\ new\ post\ in\ {site_esc} {title_esc}\ by\ {author_esc}', )

    # The command I use, the Linux default:
    posix = (r'notify-send A\ new\ post\ in\ {site_esc} {title_esc}\ by\ {author_esc}', 'mplayer -really-quiet /usr/share/sounds/purple/receive.wav')

    # An example of a command on Windows
    default = (r'C:\Program Files\VideoLAN\VLC\vlc.exe C:\skyrocket_explode.mp3', )
For the rest, read the comments in the script and learn Python 3 yourself, please, because I hate writing documentations. :D

Hopefully you are not sleepy after reading all the boring stuffs above. :) Script is right here:
https://github.com/richardgv/newpostsche...tscheck.py
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply
11-15-2010, 10:02 PM,
#2
RE: Forum New Posts Notifier for NiftyHost
Richard, this is what makes you an awesome addition to staff. Before this, I relied on the New Threads RSS and frequent refreshs of the New Posts page.
Hi! I'm Zach, and I founded NiftyHost. If you need anything, just PM me! :)
Reply
11-16-2010, 12:31 AM, (This post was last modified: 11-16-2010, 12:33 AM by RichardGv.)
#3
RE: Forum New Posts Notifier for NiftyHost
Nightly 20101116:
http://stc.hux.pp.ru/newpostscheck_20101116.py
This version did not include many changes for NiftyHost.
  1. Generic support for MyBB "friendly" redirection (I would rather say troublesome :D ).
  2. A bug that may cause title matching issues for staffs is fixed.
  3. Added support for another forum (SerialExperience).
  4. Option 'enable' to enable/disable support for a specific site.

(11-15-2010, 10:02 PM)Zack Wrote: Richard, this is what makes you an awesome addition to staff. Before this, I relied on the New Threads RSS and frequent refreshs of the New Posts page.

Thanks. :) So, it works for you? Don't hesitate to post a bug report if you meet a bug. So far nobody has ever told me whether it works.
Also, looks like most people are uninterested. Is the script plainly too hard for them to use?
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply
11-16-2010, 05:18 AM, (This post was last modified: 11-16-2010, 05:21 AM by Vanilla.)
#4
RE: Forum New Posts Notifier for NiftyHost
That's kinda neat! :) - Thanks for writing/providing it!

But, if I may:
- It would be nice to have the login info made more visible (ie. be under some sort of settings sections/function)
- I can confirm it working partially under Windows 7 - I was able to see the latest new post/thread, but i also got an error:
Code:
Checking the state of niftyhost...
A new post in niftyhost: Who play the flash game? by 903: http://www.niftyhost.us/support/thread-677-lastpost.html
Traceback (most recent call last):
  File "*FILE DIR*", line 172, in <module>
    newpostscheck(i)
  File "*FILE DIR*", line 129, in newpostscheck
    os.system(cmd.format(site = key, title = titlematch, author = authormatch, url = urlmatch))
KeyError: 'site_esc'
- The "*FILE DIR* thing is just the location of my python file, don't mind it.

But nice work, nonetheless ;)
Reply
11-16-2010, 10:48 AM, (This post was last modified: 11-16-2010, 11:43 AM by RichardGv.)
#5
RE: Forum New Posts Notifier for NiftyHost
I'm adding support for vBulletin forums and SMF forums. (By the way, I'm kind of surprised that vBulletin uses MD5 on client side when submitting password!) But the vBulletin site I'm testing on have no new posts currently, and the SMF one is totally down. :) So I need to wait for some time to do a final test.

(11-16-2010, 05:18 AM)Vanilla Wrote: But, if I may:
- It would be nice to have the login info made more visible (ie. be under some sort of settings sections/function)
- I can confirm it working partially under Windows 7 - I was able to see the latest new post/thread, but i also got an error:

The configuration is only a one-time work, so it's not too much a burden, but maybe I will consider splitting the configuration to a separate file once the script gets stable. Currently I could update the script everyday so splitting the configuration will only create more troubles when upgrading.

As for the exception, Vanilla, I thought you would at least carefully read the bold parts in my thread, but you did not, unfortunately. Your problem is caused by the default value of the option 'cmdexec', which is designed purely for Linux users instead of Windows users. I've stated that point clearly in my thread, and you did not notice it. Please read the bold part:
(11-15-2010, 08:18 PM)RichardGv Wrote: Constant 'cmdexec'. Line 21. Commands executed when a new post is discovered. You can use it to, for example, play some sound or show a libnotify popup when a new post is found. It's written in the format of a Python tuple. Examples:
(The script comes with a nice default value for Linux users, but for Windows users it will cause an exception! Windows users may change it to the blank value "cmdexec = ()".)
Code:
# No command is the best command :D
cmdexec = ()

# Attention: If there's only a single string in the tuple, you need to add an extra comma after the string.
cmdexec = ('notify-send "{site}" "{title} by {author}"', )

# The command I use:
cmdexec = (r'notify-send A\ new\ post\ in\ {site_esc} {title_esc}\ by\ {author_esc}', 'mplayer -really-quiet /usr/share/sounds/purple/receive.wav')
# {site_esc} = shell-escaped {site}. And so forth...

# An example of a command on Windows
cmdexec = (r'C:\Program Files\VideoLAN\VLC\vlc.exe C:\skyrocket_explode.mp3', )
The reason why it fails, technically, is {site_esc}, {title_esc}, and {author_esc} are all not provided for Windows, since they are shell-escaped in Unix fashion.
In order to use the script on Windows, you need to change 'cmdexec' to a more reasonable value. For example, the first and the last example are both usable under Windows. With the last example, you can play a sound with VLC when there's a new post. (But make sure you change the path of VLC and the music file to a valid local path.)
Code:
# No command is the best command :D
cmdexec = ()

# An example of a command on Windows
cmdexec = (r'C:\Program Files\VideoLAN\VLC\vlc.exe C:\skyrocket_explode.mp3', )
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply
11-16-2010, 01:07 PM,
#6
RE: Forum New Posts Notifier for NiftyHost
To make it easier to use, I woulduse the python compiler and cygwin or something to make a .exe when you have a final release. A majority of users have Windows.
Hi! I'm Zach, and I founded NiftyHost. If you need anything, just PM me! :)
Reply
11-16-2010, 01:26 PM, (This post was last modified: 11-16-2010, 01:27 PM by RichardGv.)
#7
RE: Forum New Posts Notifier for NiftyHost
(11-16-2010, 01:07 PM)Zack Wrote: To make it easier to use, I woulduse the python compiler and cygwin or something to make a .exe when you have a final release. A majority of users have Windows.

Yeah, I can use py2exe or cx_freeze to pack it, but:
  1. I hate Windows users... :D
  2. The configuration part is placed in the script text itself, so once it's compiled by CPython to a .pyo file, the configuration can no longer be changed. If I put the configuration part outside and import it with eval(), I'm not sure whether a packed Python interpreter will work. Maybe I can create a config file parser with xml library...
  3. Installing Python 3.1 (on Windows) won't kill any users. (Well, in most cases it won't, at least. :D ) It's 13MB only. Afterall, these lazy Windows users really need an exercise. :D If they have Python installed, they will be able to use other scripts or randomly edit my script, too.
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply
11-16-2010, 05:04 PM, (This post was last modified: 11-16-2010, 05:10 PM by Vanilla.)
#8
RE: Forum New Posts Notifier for NiftyHost
Quote:As for the exception, Vanilla, I thought you would at least carefully read the bold parts in my thread, but you did not, unfortunately. Your problem is caused by the default value of the option 'cmdexec', which is designed purely for Linux users instead of Windows users. I've stated that point clearly in my thread, and you did not notice it. Please read the bold part

Well, sorry about that. As a lazy gaming windows user, you didn't expect me to both install Python, and then read the text thoroughly :P
Well, tested it again (after having read the bold text), and now it works :)
Reply
11-18-2010, 07:47 PM, (This post was last modified: 11-18-2010, 07:50 PM by RichardGv.)
#9
RE: Forum New Posts Notifier for NiftyHost
Nightly 20101117:
http://stc.hux.pp.ru/newpostscheck_20101117.py
This version did not include many changes for NiftyHost.
  1. Generic support for vBulletin MD5-ed password.
  2. 'username' and 'password' are moved to the beginning of the lines.
  3. Added support for 2 other forums.
  4. 'cmdexec' default value set to blank. (I resign to the "lazy" Windows users that does not read my thread carefully...)

Nightly 20101118: (The version number is way ahead of the actual time! :D )
http://stc.hux.pp.ru/newpostscheck_20101118.py
This version did not include many changes for NiftyHost.
  1. Generic support for SMF SHA-1 authentication.
  2. Added support for another forum.

Nightly 20101119:
http://stc.hux.pp.ru/newpostscheck_20101119.py
Fixes a bug that causes the script to throw an exception when a MyBB forum has a new post with more than one page of replies
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply
11-20-2010, 03:47 PM,
#10
RE: Forum New Posts Notifier for NiftyHost
Just by a quick glance, it looks and sounds pretty good.
Good job. :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How did you find Niftyhost? Serial Thrilla 21 5,631 06-29-2012, 07:26 AM
Last Post: Jennifer
  NiftyHost Server Monitor (created by Piotr GRD) Piotr GRD 21 13,023 01-18-2012, 05:12 AM
Last Post: Serial Thrilla
  OMG COLORS! A Niftyhost Production pspboy 12 4,556 01-18-2012, 05:01 AM
Last Post: Serial Thrilla
  NiftyHost Affiliate System MyDigitalpoint 4 2,058 10-09-2011, 01:12 PM
Last Post: cuckooz
Information How To Run A Board Forum Like myBB And SMF in Your Own PC [just for fun]! KSubedi 31 18,981 08-15-2011, 10:26 AM
Last Post: MyDigitalpoint
  Niftyhost (Forums) reaches 500 registered members Vanilla 36 8,798 06-26-2011, 06:28 AM
Last Post: micro

Forum Jump: