def execute(cls, slack_wrapper, args, channel_id, user_id, user_is_admin): """Execute the Version command.""" try: message = GitHandler(".").get_version() slack_wrapper.post_message(channel_id, message) except: log.exception("BotHandler::VersionCommand") raise InvalidCommand("Sorry, couldn't retrieve the git information for the bot...")
def post_ctf_data(ctf, title): """Create a post and a statistic file and upload it to the configured SolveTracker repository.""" if not ST_GIT_SUPPORT: raise Exception( "Sorry, but the SolveTracker support isn't configured...") try: now = datetime.datetime.now() post_data = resolve_ctf_template( ctf, title, "./templates/post_ctf_template", "./templates/post_challenge_template") post_filename = "_posts/{}-{}-{}-{}.md".format(now.year, now.month, now.day, ctf.name) stat_data = resolve_stats_template(ctf) stat_filename = "_stats/{}.json".format(ctf.name) git = GitHandler(ST_GIT_CONFIG.get("git_repopath")) git.add_file(post_data, post_filename) git.add_file(stat_data, stat_filename) git.commit("Solve post from {}".format(ctf.name)) git.push(ST_GIT_CONFIG.get("git_repouser"), ST_GIT_CONFIG.get("git_repopass"), ST_GIT_CONFIG.get("git_remoteuri"), ST_GIT_CONFIG.get("git_branch")) return ST_GIT_CONFIG.get("git_baseurl") except InvalidCommand as invalid_cmd: # Just pass invalid commands on raise invalid_cmd except Exception: log.exception("SolvePostHelper") raise InvalidCommand( "Something with your configuration files doesn't seem to be correct. Please check your logfiles..." )