mò
fêjGc           @   s¤   d  Z  d Z d k Z d k Z d k Z d k Z d k Z d k Z d g Z d d d „ Z
 d e i f d „  ƒ  YZ d d „ Z d „  Z e d	 j o e ƒ  n d S(
   s    Grab a random grouphug string s!   Avleen Vig <work@silverwraith.comNt   grouphugc         C   sj   t  i d ƒ } t  i d | Œ } t i | | |  ƒ } |  d j o t
 | ƒ } n t i | | | ƒ d  S(   Nt   commonR    (   t   impt   find_modulet   module_locationt   load_modulet   moduleR   t   NormalizeMessaget   msgt   irct   keywordt   GrouphugLookupt   resultt   DeliverMessaget   channel(   R
   R   R	   R   R   R   R   (    (    tB   /home/avleen/devel/python/googlebot2/modules/googlebot_grouphug.pyt   Gather   s    t
   MLStripperc           B   s#   t  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   |  i ƒ  g  |  _ d  S(   N(   t   selft   resett   fed(   R   (    (    R   t   __init__   s    
c         C   s   |  i i | ƒ d  S(   N(   R   R   t   appendt   d(   R   R   (    (    R   t   handle_data   s    c         C   s   d i  |  i ƒ S(   Nt    (   t   joinR   R   (   R   (    (    R   t   get_fed_data    s    (   t   __name__t
   __module__R   R   R   (    (    (    R   R      s   		c   	      C   sº   |  o d |  } n d } t i | ƒ i ƒ  } d } t i | t i	 ƒ } d | i | ƒ i d ƒ | i | ƒ i d ƒ f } t ƒ  } | i | ƒ | i ƒ  } t i d d | ƒ } | S(	   Ns!   http://grouphug.us/confessions/%ss   http://grouphug.us/randoms-   .*([\d]{9}).*<td class="conf-text">(.*?)</td>s   %s: %si   i   s	   ([
	\s]+)t    (   t
   confessiont   urlt   urllibt   urlopent   readt   htmlt   patternt   ret   compilet   DOTALLt   confession_pt   matcht   groupt   confession_htmlR   t   strippert   feedR   t   confession_textt   subt   formatted_confession_text(	   R   R,   R    R%   R)   R$   R1   R/   R-   (    (    R   R   $   s    4	c          C   sƒ   y t  i d }  Wn  t j
 o t  i d ƒ n Xy t  i d } Wn t j
 o d  } n X|  t j o t |  | ƒ n d  S(   Ni   i   (	   t   syst   argvR
   t
   IndexErrort   exitt   argumentt   Nonet   module_triggersR   (   R
   R6   (    (    R   t   main5   s    t   __main__(   t   __doc__t
   __author__t
   HTMLParserR   R   R&   R2   R!   R8   R7   R   R   R   R9   R   (   R&   R   R!   R<   R2   R   R   R=   R   R   R9   R8   (    (    R   t   ?   s   								
	
