#NEWLINE# @ irc3 . extend #NEWLINE# def print_help_page( bot , file = sys . stdout ) : #NEWLINE# #INDENT# 'print help page' #NEWLINE# def p( text ) : #NEWLINE# #INDENT# print ( text , file = file ) #NEWLINE# #UNINDENT# plugin = bot . get_plugin ( Commands ) #NEWLINE# title = 'Available Commands for {nick} at {host}' . format ( ** bot . config ) #NEWLINE# p ( ( '=' * len ( title ) ) ) #NEWLINE# p ( title ) #NEWLINE# p ( ( '=' * len ( title ) ) ) #NEWLINE# p ( '' ) #NEWLINE# p ( '.. contents::' ) #NEWLINE# p ( '' ) #NEWLINE# modules = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( name , ( predicates , callback ) ) in plugin . items ( ) : #NEWLINE# #INDENT# commands = modules . setdefault ( callback . __module__ , [ ] ) #NEWLINE# commands . append ( ( name , callback , predicates ) ) #NEWLINE# #UNINDENT# for module in sorted ( modules ) : #NEWLINE# #INDENT# p ( module ) #NEWLINE# p ( ( '=' * len ( module ) ) ) #NEWLINE# p ( '' ) #NEWLINE# for ( name , callback , predicates ) in sorted ( modules [ module ] ) : #NEWLINE# #INDENT# p ( name ) #NEWLINE# p ( ( '-' * len ( name ) ) ) #NEWLINE# p ( '' ) #NEWLINE# doc = callback . __doc__ #NEWLINE# doc = doc . replace ( '%%' , bot . config . cmd ) #NEWLINE# for line in doc . split ( '\n' ) : #NEWLINE# #INDENT# line = line . strip ( ) #NEWLINE# if line . startswith ( bot . config . cmd ) : #NEWLINE# #INDENT# line = '    ``{}``' . format ( line ) #NEWLINE# #UNINDENT# p ( line ) #NEWLINE# #UNINDENT# if ( 'permission' in predicates ) : #NEWLINE# #INDENT# p ( '*Require {0[permission]} permission.*' . format ( predicates ) ) #NEWLINE# #UNINDENT# if ( predicates . get ( 'public' , True ) is False ) : #NEWLINE# #INDENT# p ( '*Only available in private.*' ) #NEWLINE# #UNINDENT# p ( '' )