kopia lustrzana https://github.com/mkdryden/telegram-stats-bot
stats: Allow autouser arg in parser
rodzic
6856b82a25
commit
170a2dfed1
13
main.py
13
main.py
|
@ -107,7 +107,18 @@ def print_stats(update: Update, context: CallbackContext):
|
||||||
func = args.pop('func')
|
func = args.pop('func')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if args['me']:
|
if args['user']:
|
||||||
|
try:
|
||||||
|
uid = args['user']
|
||||||
|
args['user'] = uid, stats.users[uid][0]
|
||||||
|
except KeyError:
|
||||||
|
send_help("unknown userid", context, update)
|
||||||
|
return
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if args['me'] and not args['user']: # Lets auto-user work by ignoring auto-input me arg
|
||||||
args['user'] = update.effective_user.id, update.effective_user.name
|
args['user'] = update.effective_user.id, update.effective_user.name
|
||||||
del args['me']
|
del args['me']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
5
stats.py
5
stats.py
|
@ -449,6 +449,11 @@ def get_parser(runner: StatsRunner) -> InternalParser:
|
||||||
group = subparser.add_mutually_exclusive_group()
|
group = subparser.add_mutually_exclusive_group()
|
||||||
group.add_argument('-me', action='store_true', help='calculate stats for yourself')
|
group.add_argument('-me', action='store_true', help='calculate stats for yourself')
|
||||||
group.add_argument('-user', type=int, help=argparse.SUPPRESS)
|
group.add_argument('-user', type=int, help=argparse.SUPPRESS)
|
||||||
|
elif arg.name == 'autouser':
|
||||||
|
subparser.set_defaults(me=True)
|
||||||
|
subparser.add_argument('-user', type=int, help=argparse.SUPPRESS)
|
||||||
|
elif arg.name == 'kwargs':
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
if doc:
|
if doc:
|
||||||
arg_doc = None
|
arg_doc = None
|
||||||
|
|
Ładowanie…
Reference in New Issue