Small API for getting the events in multiple discord servers and Google Agenda with easier parsing for Resonite.
This tool has been write in a way that different community can host their own server and can be connected to each other. There is a main instance available at resonite-communities.com.
This is the new version 2.0, not tested in production yet, please see the git tag for the version 1.0.
Most of the configuration of this tool are available in the config.toml
file and the following configuration
keys are available:
DISCORD_BOT_TOKEN
: The bot token, in a string format.SERVERS_EVENT
: A list of string URL of other events server to aggregate in the format of 'scheme://host:port'SHOW_WEBUI
: Enable or now the WebUI, depend if the tool will be used as an API only or no.FACET_URL
: The URL of the facet to be copied for Resonite
The different source of information are separated in modules. Each module have is own configuration per event.
Note: If the configuration is change you should clean the Redis database!
The source module for discord integrated schedule event system.
For adding a guild to this source you need to use the key
[[BOTS.DiscordScheduledEvents]]
and add the following key:
community_name
: str, the name of the communitycommunity_description
: str, the description of the communitycommunity_url
: str, the URL where to find this community, can be a discord invite link or a websitetags
: list, the list of tagsguild_ids
: int, the guild id
Not: Not yet available
It's possible to send all events in a cloud variable to be used by JackTheOtter calendar system.
CLOUDVAR_RESONITE_USER
: str, theU-
Resonite username used to set the cloud variableCLOUDVAR_RESONITE_PASS
: strCLOUDVAR_BASE_NAME
: str, the Resnonite cloud variable base nameCLOUDVAR_GENERAL_NAME
: str, the Resnonite cloud variable general name
[[BOTS.DiscordScheduledEvents]]
community_name = "The Vulpine Garden"
community_description = "The Vulpine Garden Community"
community_url = "https://discord.gg/GwQXurvt"
tags = ['karaoke']
guild_id = xxxxxxxxxxxxxxxxxx
The source module for fetch events from Google Calendar.
For adding a guild to this source you need to use the key
[[BOTS.GoogleCalendar]]
and add the following keys:
communities_name
: list, the list of the names of the communities handled by this Google calendaremail
: str, the email of the Google calendarcredentials_file
: str, the path of the configuration file
[[BOTS.GoogleCalendar]]
communities_name = ['Creator Jam']
email = "[email protected]"
credentials_file = 'credentials.json'
The source module for fetch events from the Discord Apollo bot.
For adding a guild to this source you need to use the key
[[BOTS.Apollo]]
and add the following keys:
community_name
: str, the name of the communitycommunity_description
: str, the description of the communitycommunity_url
: str, the URL where to find this community, can be a discord invite link or a websitetags
: list, the list of tagsguild_ids
: int, the guild idguild_channel
: str, the name of the channel where the Apollo bot is publishing new eventsbot
: int, the bot id
[[BOTS.Apollo]]
community_name = "The Vulpine Garden"
community_description = "The Vulpine Garden Community"
community_url = "https://discord.gg/GwQXurvt"
tags = ['karaoke']
guild_id = xxxxxxxxxxxxxxxxxx
guild_channel = "events"
bot = xxxxxxxxxxxxxxxxxx
Fetches events from JSON over http.
For config, you need to use the key [[BOTS.JSONEventsCollector]]
and have the following keys:
community_name
: str, The community nameevents_url
: str, The URL to get events from
You can also add
community_description
: str, The description of the communitytags
: array, community tags
Required keys in the JSON response:
name
: The name of the eventdescription
: The event descriptionstart_time
: The start time of the event in an ISO timestamp (must be in UTC)end_time
: The end time of the event in an ISO timestamp (must be in UTC)location
: The location of the event
An example config to be put in config.toml
:
[[BOTS.JSONEventsCollector]]
community_name = "Example Name"
community_description = "Example Description"
events_url = "https://example.com/events_json"
tags = ['example']
An example response from the endpoint:
[
{
"name": "Example Name",
"description": "Example description",
"location": "Example's session",
"start_time": "2024-04-20T00:00:00+00:00",
"end_time": "2024-04-20T02:00:00+00:00"
}
]
This tools also give the ability to list planned Resonite streams from a selection of users.
TWITCH_CLIENT_ID
: The Twitch client IDTWITCH_SECRET
: The Twitch client SecretTWITCH_STREAMS
: List of Twitch users to followTWITCH_GAME_ID
: Resonite Twitch game ID (Default to current Resonite ID)TWITCH_RESONITE_ACCOUNT_NAME
: Official Resonite Twitch (Default to current Official Resonite Twitch Account)
As an example there is a compose file for start the full project really easy.
If you want to launch the project without docker you will need a Redis database. This project is then separated in two parts, the calendar update system and the calendar application by itself. This two parts can be executed separately and are totally independent from each other but the two depend of the redis database to work.
For the two applications there is an env variable for set the
redis host: REDIS_HOST
, it default to cache
.
The calendar update system work in a way that its always listen to discord events and as a cron job, every 5 minutes to check for missed events or in case of a reboot of this system.
The calendar update system can simply by launch via:
python bot.py
The bots
folder contains a list of modules to get events from. While
most of them are and will be for discord bot there is actually two
exception, for now. The module called google
and discord
are
for Google Calendar and Discord integrated event system. All of the
bot are based on the class Bot
in the _base.py
file.
The calendar application is the system who will handle both API and web request for now.
The calendar application can simply by launch via
gunicorn -w 4 -b 0.0.0.0:5000 app:app
Note: This endpoint is noted as deprecated
/v1/events
: return the list of the event in an easy readable format for Resonite:name`description`location`start_time`end_time`community_name\n\r
Note: The last line don't have\n\r
/v1/aggregated_events
: same format as/v1/events
but return the list of aggragated events from this instance with the ones from the instance listed in the config variableSERVER_EVENTS
/
: WebUI client
Both endpoints events
and aggregated_events
have the possibility to have only some community
listed with the querystring communities
who take as a parameters a list of community name
separated by a coma.
They also return a list of events from a Google calendar. See configuration below.
/v2/communities
: return the list of the communities available on this event server/v2/events
: return the list of the event in an easy readable format for Resonite:\n\r
Note: The last line don't have\n\r
/v2/aggregated_events
: same format as/v2/events
but return the list of aggragated events from this instance with the ones from the instance listed in the config variableSERVER_EVENTS
/
: WebUI client
Its possible to see the list of events available in Resonite via a facet.
You can find the last version available in the public folder at this
address: resrec:///U-GrayBoltWolf/R-6D21762A77D6D5F16D03C0163191BD068DCBA62DC7869C1C64E916ECDEFDEBC9
The WebUI client is directly using the functions internally and don't talk to the API in HTTP. Its use a simple css framework called Bulma and are loaded directly from differents CDN for now.
Date are formated directly without taking in account of the timezone of the webbrowser.
There is a support of the discord timestamp but only for the R
format.
And the resonite session URL is automaticaly detected from the description if no URL already present in the locatization parameter.
It will automaticaly use the first, and only the first, URL starting with http(s)://cloudx.azurewebsites.net
for set the locatization
parameter.
For adding a google agenda you need:
- create a Google calendar with your personal account
- create, or use, a Google Cloud Plateform account and create a new project. Enable the calendar API on it and create a
Service Account
with ajson
API key. Then you need to add the email of this Service Account API key as an authorized user of your personal Google calendar. - Copy the
json
file next to the project or where you want on the system. - Update the
config.toml
configuration depending on your need.
Note: The id of the calendar is in the settings of your Google Calendar under calendar integration.
For found what is the id of a guild you can use the script get_discord_server_list.py
who return the list of guild where the bot is
present.
Since the source can also contains event who can happen in different location, either virtually or physically, the keyword
Resonite
must be specified either in the title
, the description
, or the location
of an event. New lines and some special
chars before being lowered.
The Apollo bot is a special case since this bot doesn't support a 'location' field this one must be added in the description in the
following format: Location: <event location>
. For a correct detection this field should be on his own line. Don't forget to put a
carriage return if you add test after and put a space before the L
.