<s> from telex . plugin import TelexPlugin <EOL> class HelpPlugin ( TelexPlugin ) : <EOL> """<STR_LIT>""" <EOL> patterns = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> usage = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] <EOL> def run ( self , msg , matches ) : <EOL> if matches . group ( <NUM_LIT:0> ) [ <NUM_LIT:1> : ] == "<STR_LIT>" : <EOL> return self . telegram_help ( ) <EOL> text = self . plugin_help ( matches . group ( <NUM_LIT:1> ) ) <EOL> if text is None : <EOL> return self . telegram_help ( ) <EOL> else : <EOL> return text <EOL> def plugin_help ( self , name ) : <EOL> text = None <EOL> plugin = self . plugin_manager . getPluginByName ( name ) <EOL> if plugin is not None : <EOL> if plugin . plugin_object . is_activated : <EOL> text = "<STR_LIT>" . format ( plugin . name , plugin . description ) <EOL> if hasattr ( plugin . plugin_object , '<STR_LIT>' ) : <EOL> text += "<STR_LIT:\n>" . join ( plugin . plugin_object . usage ) <EOL> text = text . replace ( '<STR_LIT>' , self . bot . pfx ) <EOL> else : <EOL> text += "<STR_LIT>" <EOL> else : <EOL> text = "<STR_LIT>" . format ( plugin . name ) <EOL> return text <EOL> def telegram_help ( self ) : <EOL> text = "<STR_LIT>" <EOL> for plugin in self . plugin_manager . getAllPlugins ( ) : <EOL> if plugin . plugin_object . is_activated : <EOL> text += "<STR_LIT>" . format ( plugin . name , plugin . description ) <EOL> text += "<STR_LIT>" <EOL> text = text . replace ( '<STR_LIT>' , self . bot . pfx ) <EOL> return text </s>
