Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Post code

Name: Anonymous 2011-10-06 9:06

Any code you work with right now, and we'll criticize it(or not).

Name: Anonymous 2011-10-06 9:33

Working on a python irc script that sends out streams that are live to users who trigger it.



def check_online_own3d(streamID):
    f = urllib.urlopen("http://api.own3d.tv/liveCheck.php?live_id=" + streamID)
    liveLink = f.read()
    f.close()
   
    if '<isLive>true</isLive>' in liveLink:
        ready = 1
    else:
        ready = 0
  
    return ready


def on_text(word, word_eol, userdata):
    destination = xchat.get_context()
    triggernick = word[0]
    trigger = re.split(' ', word[1].lower())
   
    if trigger[0] == '!stream' and trigger[1] == 'list':
        strStreamListOwn3d = 'none'
        liveStreamListOwn3d = []
        inStreamListOwn3d = []
        #own3d
        loop = 0
        infile = open(os.path.join("C:\\Program Files\\XChat-WDK\\plugins\\streamFiles", "streamListOwn3d.txt"))
        findingLine = infile.readlines()
        infile.close()
        for i in findingLine:
            streamID = findingLine[loop].strip()
            if check_online_own3d(streamID) == 1:
                inStreamListOwn3d.append(streamID)
            loop += 1
       
       
        if '40553' in inStreamListOwn3d:
                 liveStreamListOwn3d.append('http://www.own3d.tv/live/40553/ComeWithMe')

        strStreamListOwn3d = str(liveStreamListOwn3d)
        
        if liveStreamListOwn3d == []:
            destination.command("say " + triggernick + ": No live streams currently online.")
        else:
            destination.command("say " + triggernick + ": Live Streams are " + strStreamListOwn3d)
       
       
        return xchat.EAT_NONE


xchat.hook_print('Channel Message', on_text)


Would appearciate help to optimize the bit that checks if it is online. Right now it takes about 10 secs to reply with the live links.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List