Syodosima
Syodosima gem is a tool to notify Discord of appointments on a given Google Calendar and provides a CLI wrapper.
Installation
Install the gem and add to the application's Gemfile by executing:
bundle add syodosimaIf bundler is not being used to manage dependencies, install the gem by executing:
gem install syodosimaFor manual installation, follow these steps.
- Clone the repository:
git clone https://github.com/Desert-sabaku/syodosima.git
cd syodosima- Install dependencies:
bundle installUsage
Syodosima automatically retrieves today's appointments from Google Calendar and sends notifications to a Discord channel.
Features
- Automatically retrieve today's appointments from Google Calendar
- Properly display timed events and all-day events
- Send notifications to Discord channels
- Support for automatic execution in GitHub Actions
Configuration
Google Calendar API Setup
- Create a new project in Google Cloud Console
- Enable Google Calendar API
- Create credentials (OAuth 2.0 Client ID)
- Download the
credentials.jsonfile
Discord Bot Setup
- Create a new application in Discord Developer Portal
- Create a bot and obtain the token
- Invite the bot to the server and obtain the channel ID
Environment Variable Setup
Please set the following environment variables:
For Local Execution
Create a .env file and describe the following:
DISCORD_BOT_TOKEN=your_discord_bot_token_here
DISCORD_CHANNEL_ID=your_channel_id_here
GOOGLE_CREDENTIALS_JSON={"type":"service_account","project_id":"..."} # contents of credentials.json
GOOGLE_TOKEN_YAML=credentials_yaml_content_here # contents of token.yamlFor GitHub Actions Execution
Set the following secrets in GitHub repository Settings > Secrets and variables > Actions:
-
DISCORD_BOT_TOKEN: Discord Bot token -
DISCORD_CHANNEL_ID: Discord channel ID to send notifications to -
GOOGLE_CREDENTIALS_JSON: Contents of credentials.json file -
GOOGLE_TOKEN_YAML: Contents of token.yaml file
Running the Application
Local Execution
- For the first run, Google authentication is required. First, launch
irb:
irb(main):001> require "syodosima"
=> true
irb(main):002> Syodosima.run- Perform Google authentication in the browser and enter the displayed code in the console
- Authentication information will be saved in
token.yaml
Important
Do you have a .env file in the current directory?
Without this, syodosima will not work!
For manual installation, use the rake task instead of irb.
bundle exec rake run:onceNote
This rake task internally calls Syodosima.run.
Automatic Execution in GitHub Actions
Create a GitHub Actions workflow file (e.g., .github/workflows/notify.yml):
name: Daily Calendar Notification
on:
schedule:
- cron: "0 0 * * *" # Run daily at 0:00 (UTC)
workflow_dispatch: # Manual execution also possible
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- name: Install dependencies
run: bundle install
- name: Run notification bot
run: bundle exec rake run:once
env:
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_CHANNEL_ID: ${{ secrets.DISCORD_CHANNEL_ID }}
GOOGLE_CREDENTIALS_JSON: ${{ secrets.GOOGLE_CREDENTIALS_JSON }}
GOOGLE_TOKEN_YAML: ${{ secrets.GOOGLE_TOKEN_YAML }}Notification Example
Example of messages sent by the bot:
Good morning!
I'll let you know today's schedule.
【09:00〜10:00】 Team Meeting
【13:00〜14:00】 Project Review
【All Day】 Holiday
Notes
- Google authentication is required for the first run
- Timezone follows system settings
- Only appointments from the primary calendar in Google Calendar are retrieved
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/desert-sabaku/syodosima. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.