Monitwer

From Unallocated Space
Revision as of 12:52, 8 January 2023 by Digitaltinker (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Monitwer watches Twitter and alerts the IRC channel about any activity involving the @Unallocated account. Uses the IRC_Bot's ability to send arbitrary text into IRC.


import urllib, urllib2, os
from xml.dom import minidom

f=open('/uas/monitwer/id','r')
id=f.read()
f.close()

usock = urllib.urlopen('http://search.twitter.com/search.rss?q=%40unallocated OR from%3Aunallocated&show_user=true&result_type=recent&since_id='+id)
xmldoc = minidom.parse(usock)
usock.close()

data=xmldoc.getElementsByTagName('item')

id=0
for node in data:
        title=node.getElementsByTagName('title')[0].toxml()[7:-8].replace("\n",'').encode('utf-8')
        link =node.getElementsByTagName('link')[0].toxml()[6:-7]
        if id is 0:
                id=link[link.find('/statuses/')+10:]
                f=open('/uas/monitwer/id','w')
                f.write(str(id))
                f.close()
        title=title.replace("'",'')
        title=title.replace('"','')
        title=title.replace('$','')#ala Tuna
        title=title.replace('`','')#ala Oryx
        print title
        os.system('echo "New Twitter Alert: @'+title+'" > /uas/irc/irc')