Example #1
0
def postDraftingMessage(playerList):

	with open('app/pairings.settings') as config:
		settings = json.loads(config.read())

	if app.config['TESTING'] == True:
		channel = settings['testing_channel_name']
	else:
		channel = settings['channel_name']
	pairings_bot = slack_bot(settings['channel_url'], channel, settings['bot_name'], settings['bot_icon'])

	if playerList:

		message = ''
		for player in playerList:

			message += player + '\n'

		attachment = {
				'title': "Enough people have raised their horned hands to the God-Pairaoh, and he has answered! Praise Him!",
				'text': message,
				'color': "#7CD197",
				'mrkdwn_in': ["text"]
				 }

		pairings_bot.post_attachment(attachment)
Example #2
0
def postDraftingMessage(playerList):

    with open('app/pairings.settings') as config:
        settings = json.loads(config.read())

    if app.config['TESTING'] == True:
        channel = os.environ['TESTING_CHANNEL_ID']
    else:
        channel = os.environ['CHANNEL_ID']
    pairings_bot = slack_bot(channel, settings['bot_name'],
                             settings['bot_icon'])

    if playerList:

        message = ''
        for player in playerList:

            message += player + '\n'

        attachment = {
            'title':
            "Enough people have raised their horned hands to the God-Pairaoh, and he has answered! Praise Him!",
            'text': message,
            'color': "#7CD197",
            'mrkdwn_in': ["text"]
        }

        pairings_bot.post_attachment(attachment)
Example #3
0
def slackResults(id):

	
	with open('app/results.settings') as config:
		settings = json.loads(config.read())

	if app.config['TESTING'] == True:	
		channel = settings['testing_channel_name']
	else:	
		channel = settings['channel_name']
	results_bot = slack_bot(settings['channel_url'], channel, settings['bot_name'], settings['bot_icon'])

	tournament = getTournamentResults(id)

	outPlayers = ''
	outMatchWins = ''
	outPercentage = ''

	tournamentName = getTournamentName(id)

	title = tournamentName + ' Results'
	for row in tournament:
		outPlayers = ''
		for idx, player in enumerate(row.entity.participants):
			if idx > 0:
				outPlayers += ' & '
			outPlayers += player.player.name

		print(str(row.position) + ' ' + outPlayers)
		if row.position == 1 and outPlayers == 'Alex L':
			results_bot.post_attachment(victoryMessage(tournamentName))

		outPercentage += '{!s}.\t{!s}%\n'.format(row.position, round(row.game_win_percentage,1))
		outMatchWins += '{!s}. {!s} :   {!s} / {!s}\n'.format(row.position, outPlayers, row.match_wins, row.match_losses)

	attachment = {
			'title': title,
            'fields': [
                {
                    'title': "Match Wins/Losses",
                    'value': outMatchWins,
                    'short': "true"
                },
                {
                    'title': "Game Win %",
                    'value': outPercentage,
                    'short': "true"
                }               
            ],
            'color': "#F35A00"
        }

	results_bot.post_attachment(attachment)
Example #4
0
def slackResults(id):

    with open('app/results.settings') as config:
        settings = json.loads(config.read())

    if app.config['TESTING'] == True:
        channel = settings['testing_channel_name']
    else:
        channel = settings['channel_name']
    results_bot = slack_bot(settings['channel_url'], channel,
                            settings['bot_name'], settings['bot_icon'])

    tournament = getTournamentResults(id)

    outPlayers = ''
    outMatchWins = ''
    outPercentage = ''

    tournamentName = getTournamentName(id)

    title = tournamentName + ' Results'
    for row in tournament:
        outPlayers = ''
        for idx, player in enumerate(row.entity.participants):
            if idx > 0:
                outPlayers += ' & '
            outPlayers += player.player.name

        print(str(row.position) + ' ' + outPlayers)

        outPercentage += '{!s}.\t{!s}%\n'.format(
            row.position, round(row.game_win_percentage, 1))
        outMatchWins += '{!s}. {!s} :   {!s} / {!s}\n'.format(
            row.position, outPlayers, row.match_wins, row.match_losses)

    attachment = {
        'title':
        title,
        'fields': [{
            'title': "Match Wins/Losses",
            'value': outMatchWins,
            'short': "true"
        }, {
            'title': "Game Win %",
            'value': outPercentage,
            'short': "true"
        }],
        'color':
        "#F35A00"
    }

    results_bot.post_attachment(attachment)
Example #5
0
def slackPairings(normalPairings, twoHeadedPairings, remainder):

    with open("app/pairings.settings") as config:
        settings = json.loads(config.read())

    if app.config["TESTING"] == True:
        channel = settings["testing_channel_name"]
    else:
        channel = settings["channel_name"]
    pairings_bot = slack_bot(settings["channel_url"], channel, settings["bot_name"], settings["bot_icon"])

    if not normalPairings and not twoHeadedPairings:
        attachment = {
            "title": "Uh oh!",
            "text": "There are no match pairings. Must be time to draft!",
            "color": "#7CD197",
        }

        pairings_bot.post_attachment(attachment)
    else:
        attachment = {"title": "Today's magical pairings:", "color": "#7CD197"}

        pairings_bot.post_attachment(attachment)

        if twoHeadedPairings:
            for twoHeadedPairing in twoHeadedPairings:

                message = (
                    "*"
                    + twoHeadedPairing[1][0]
                    + "* and *"
                    + twoHeadedPairing[1][1]
                    + "* vs *"
                    + twoHeadedPairing[1][2]
                    + "* and *"
                    + twoHeadedPairing[1][3]
                    + "* \n"
                    + twoHeadedPairing[0]
                )

                attachment = {"text": message, "color": "#7CD197", "mrkdwn_in": ["text"]}

                pairings_bot.post_attachment(attachment)

        if normalPairings:
            for normalPairing in normalPairings:

                message = "*" + normalPairing[1][0] + "* vs *" + normalPairing[1][1] + "* \n" + normalPairing[0]

                attachment = {"text": message, "color": "#7CD197", "mrkdwn_in": ["text"]}

                pairings_bot.post_attachment(attachment)

        if remainder:

            message = "*No games for these chumps:*\n"

            for player in remainder:

                message += player + "\n"

            attachment = {"text": message, "color": "#7CD197", "mrkdwn_in": ["text"]}

            pairings_bot.post_attachment(attachment)
Example #6
0
def slackPairings(normalPairings, twoHeadedPairings, remainder):

    with open('app/pairings.settings') as config:
        settings = json.loads(config.read())

    if app.config['TESTING'] == True:
        channel = settings['testing_channel_name']
    else:
        channel = settings['channel_name']
    pairings_bot = slack_bot(settings['channel_url'], channel,
                             settings['bot_name'], settings['bot_icon'])

    if not normalPairings and not twoHeadedPairings:
        attachment = {
            'title': "Uh oh!",
            'text': "There are no match pairings. Must be time to draft!",
            'color': "#7CD197"
        }

        pairings_bot.post_attachment(attachment)
    else:
        attachment = {'title': "Today's magical pairings:", 'color': "#7CD197"}

        pairings_bot.post_attachment(attachment)

        if twoHeadedPairings:
            for twoHeadedPairing in twoHeadedPairings:

                message = '*' + twoHeadedPairing[1][
                    0] + '* and *' + twoHeadedPairing[1][
                        1] + '* vs *' + twoHeadedPairing[1][
                            2] + '* and *' + twoHeadedPairing[1][
                                3] + '* \n' + twoHeadedPairing[0]

                attachment = {
                    'text': message,
                    'color': "#7CD197",
                    'mrkdwn_in': ["text"]
                }

                pairings_bot.post_attachment(attachment)

        if normalPairings:
            for normalPairing in normalPairings:

                message = '*' + normalPairing[1][0] + '* vs *' + normalPairing[
                    1][1] + '* \n' + normalPairing[0]

                attachment = {
                    'text': message,
                    'color': "#7CD197",
                    'mrkdwn_in': ["text"]
                }

                pairings_bot.post_attachment(attachment)

        if remainder:

            message = '*No games for these chumps:*\n'

            for player in remainder:

                message += player + '\n'

            attachment = {
                'text': message,
                'color': "#7CD197",
                'mrkdwn_in': ["text"]
            }

            pairings_bot.post_attachment(attachment)
Example #7
0
def slackPairings(normalPairings,twoHeadedPairings, remainder):


	with open('app/pairings.settings') as config:
		settings = json.loads(config.read())	

	if app.config['TESTING'] == True:	
		channel = settings['testing_channel_name']
	else:	
		channel = settings['channel_name']
	pairings_bot = slack_bot(settings['channel_url'], channel, settings['bot_name'], settings['bot_icon'])


	if not normalPairings and not twoHeadedPairings:
	 	attachment = {
	 				'title': "Uh oh!",
       				'text': "There are no match pairings. Must be time to draft!",
        			    'color': "#7CD197"
       			 }

	 	pairings_bot.post_attachment(attachment)
	else:	
		attachment = {
					'title': "Today's magical pairings:",
  				    'color': "#7CD197"
  				}

		pairings_bot.post_attachment(attachment)

		if twoHeadedPairings:
			for twoHeadedPairing in twoHeadedPairings:

				message = '*' + twoHeadedPairing[1][0] + '* and *' + twoHeadedPairing[1][1] + '* vs *' + twoHeadedPairing[1][2] + '* and *' + twoHeadedPairing[1][3] + '* \n' + twoHeadedPairing[0] 

				attachment = {
						'text': message,
        		    	'color': "#7CD197",
        		    	'mrkdwn_in': ["text"]
     			  	 }

				pairings_bot.post_attachment(attachment)

		if normalPairings:
			for normalPairing in normalPairings:

				message = '*' + normalPairing[1][0] + '* vs *' + normalPairing[1][1] + '* \n' + normalPairing[0] 

				attachment = {
      					'text': message,
       				    'color': "#7CD197",
       				    'mrkdwn_in': ["text"]
      				 }

				pairings_bot.post_attachment(attachment)

		if remainder:

			message = '*No games for these chumps:*\n'

			for player in remainder:

				message += player + '\n'

			attachment = {
      					'text': message,
       				    'color': "#7CD197",
       				    'mrkdwn_in': ["text"]
      				 }

			pairings_bot.post_attachment(attachment)