<s> import sys <EOL> import telepot <EOL> from telepot . delegate import per_from_id , create_open <EOL> """<STR_LIT>""" <EOL> class UserTracker ( telepot . helper . UserHandler ) : <EOL> def __init__ ( self , seed_tuple , timeout ) : <EOL> super ( UserTracker , self ) . __init__ ( seed_tuple , timeout ) <EOL> self . _counts = { '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> } <EOL> self . _answerer = telepot . helper . Answerer ( self . bot ) <EOL> def on_message ( self , msg ) : <EOL> flavor = telepot . flavor ( msg ) <EOL> self . _counts [ flavor ] += <NUM_LIT:1> <EOL> print ( self . id , '<STR_LIT::>' , <EOL> flavor , '<STR_LIT>' , '<STR_LIT::>' , <EOL> '<STR_LIT:U+002CU+0020>' . join ( [ str ( self . _counts [ f ] ) for f in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ] ) ) <EOL> if flavor == '<STR_LIT>' : <EOL> def compute_answer ( ) : <EOL> query_id , from_id , query_string = telepot . glance ( msg , flavor = flavor ) <EOL> articles = [ { '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT:id>' : '<STR_LIT:abc>' , '<STR_LIT:title>' : query_string , '<STR_LIT>' : query_string } ] <EOL> return articles <EOL> self . _answerer . answer ( msg , compute_answer ) <EOL> TOKEN = sys . argv [ <NUM_LIT:1> ] <EOL> bot = telepot . DelegatorBot ( TOKEN , [ <EOL> ( per_from_id ( ) , create_open ( UserTracker , timeout = <NUM_LIT:20> ) ) , <EOL> ] ) <EOL> bot . message_loop ( run_forever = True ) </s>
