#!/usr/bin/python # # Last Modified: 000505 # Author: N. Nordman (_nino@home.se) # # Description: # # A script that adds a /mail command for checking a pop account for mail. import XChat import poplib import string # Edit your server, user and password information here PopServer="ServerName" UserName="UserName" Pass="Password" def mail_handler(name, session, args): try: ps = poplib.POP3(PopServer) except: session.print_text('Pop-check: Could not connect to mailserver!') return else: try: ps.user(UserName) ps.pass_(Pass) nr_of_messages = ps.stat()[0] if nr_of_messages: session.print_text('You have %d new messages!' % nr_of_messages) for mess_nr in range(1, nr_of_messages + 1): session.print_text( '\n%d.' % mess_nr ) mess = ps.top(mess_nr, 0)[1] for line in mess: if string.find(line, 'From:') != -1: session.print_text('\t' + line) elif string.find(line, 'Subject:') != -1: session.print_text('\t' + line) finally: ps.quit() return # Hook up with x-chat x_chat = XChat.XChat() x_chat.register("Pop-Check", """A script that adds a command to check a pop account for mail. By N. Nordman 2000(_nino@home.se).""") x_chat.hook_command('MAIL', mail_handler) x_chat.get_current_session().print_text('Pop-check successfully loaded!')