GitXplorerGitXplorer
j

worldcup-slack-bot

public
40 stars
29 forks
1 issues

Commits

List of commits on branch master.
Verified
85ff40cc7fe83266c0e1c23ae158f4b6028b3fbd

Update example

jj0k3r committed 2 years ago
Verified
ec3f6d12a6e6cf53487cde2ff3ee822c8c5bcb35

Update for recent PHP version

jj0k3r committed 2 years ago
Verified
07a31e807604d4576635923b0bc566f6c100dfab

Add season for FIFA World Cup Qatar 2022

jj0k3r committed 2 years ago
Verified
363a50ee73406809db784ba001036aa11abf0d8c

Add information on how to find the World Cup

jj0k3r committed 6 years ago
Verified
ed35b2eb67a1086ed594a9e7f1dee52a006db5c0

Handle penalties

jj0k3r committed 7 years ago
Verified
fe6fefa7e19945cf4980c5a95d980df6ae5d363e

Merge pull request #12 from oltodo/patch-1

jj0k3r committed 7 years ago

README

The README file for this repository.

Worldcup Slack Bot

WorldCupBot will notify a Slack channel/group for every matches during a FIFA World Cup.

The API haven't changed since the Russia World Cup 2018. Which means you can use that bot for every FIFA World Cup, you just need to update ID_COMPETITION & ID_SEASON.

Find the competition you are looking for

World Cup ID_COMPETITION ID_SEASON
FIFA World Cup Russia 2018™ 17 254645
FIFA U-20 World Cup Poland 2019 104 281971
FIFA Women's World Cup France 2019™ 103 278513
FIFA World Cup Qatar 2022™ 17 255711

If the competition you are looking for isn't defined below, here is how you can find these numbers:

  • determine when the competition will start (for example 2022-11-19T00:00:00Z)
  • go to https://api.fifa.com/api/v3/calendar/matches?from=DATE_START&language=en&count=500 and replace DATE_START with the previous date (be careful to use the same format)
  • look for the competition (for example FIFA World Cup Qatar 2022)
  • get the correspondant values:
    • IdSeason
    • IdCompetition

What it does

That bot is using the "unofficial" FIFA json API (the one used for their mobile apps).

It will post a message :

  • when a match starts
  • for every red/yellow card
  • for the half time and end time
  • and of course, for every goal

Preview

Here is a preview of the United States vs Wales match (during the 2022 edition).

worldcup-slack-bot sample

Requirements

  • PHP >= 5.5 (I guess?)
  • You need to create a Slack Apps with an incoming webhooks:
    • Jump at https://api.slack.com/messaging/webhooks (you have to login)
    • Create a Slack app
    • Enable Incoming Webhooks
    • Create an Incoming Webhook (you'll then select the channel used for that bot)
    • Grab the link like https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX and put it in SLACK_URL

Installation

  • Clone this repo
  • Set up a cron to run every minute:
* * * * * cd /path/to/folder && php worldCupNotifier.php >> worldCupNotifier.log

Side notes

The code is ugly but it works.

Everything is posted in french, but feel free to fork and use your own language. FYI, FIFA API can provide text in en/fr/de/es/pt.