select by famhash: Add methods to get param in bot
We need a method as callback to get bot specific params passed through to our bot class. Introduce -famhash parameter to work on specific famhash Related Task:[FS#146](https://fs.golderweb.de/index.php?do=details&task_id=146)
This commit is contained in:
23
red.py
23
red.py
@@ -60,7 +60,7 @@ def prepare_bot( task_slug, subtask, genFactory, subtask_args ):
|
|||||||
@rtype tuple
|
@rtype tuple
|
||||||
"""
|
"""
|
||||||
# kwargs are passed to selected bot as **kwargs
|
# kwargs are passed to selected bot as **kwargs
|
||||||
kwargs = dict()
|
kwargs = subtask_args
|
||||||
|
|
||||||
if not subtask or subtask == "discparser":
|
if not subtask or subtask == "discparser":
|
||||||
# Default case: discparser
|
# Default case: discparser
|
||||||
@@ -83,6 +83,25 @@ def prepare_bot( task_slug, subtask, genFactory, subtask_args ):
|
|||||||
return ( subtask, Bot, genFactory, kwargs )
|
return ( subtask, Bot, genFactory, kwargs )
|
||||||
|
|
||||||
|
|
||||||
|
def parse_red_args( argkey, value ):
|
||||||
|
"""
|
||||||
|
Process additional args for red.py
|
||||||
|
|
||||||
|
@param argkey The arguments key
|
||||||
|
@type argkey str
|
||||||
|
@param value The arguments value
|
||||||
|
@type value str
|
||||||
|
|
||||||
|
@return Tuple with (key, value) if given pair is relevant, else None
|
||||||
|
@rtype tuple or None
|
||||||
|
"""
|
||||||
|
|
||||||
|
if argkey.startswith("-famhash"):
|
||||||
|
return ( "famhash", value )
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def main(*args):
|
def main(*args):
|
||||||
"""
|
"""
|
||||||
Process command line arguments and invoke bot.
|
Process command line arguments and invoke bot.
|
||||||
@@ -110,7 +129,7 @@ def main(*args):
|
|||||||
|
|
||||||
# Parse local Args to get information about subtask
|
# Parse local Args to get information about subtask
|
||||||
( subtask, genFactory, subtask_args ) = jogobot.bot.parse_local_args(
|
( subtask, genFactory, subtask_args ) = jogobot.bot.parse_local_args(
|
||||||
local_args )
|
local_args, parse_red_args )
|
||||||
|
|
||||||
# select subtask and prepare args
|
# select subtask and prepare args
|
||||||
( subtask, Bot, genFactory, kwargs ) = prepare_bot(
|
( subtask, Bot, genFactory, kwargs ) = prepare_bot(
|
||||||
|
|||||||
Reference in New Issue
Block a user