Skip to content

Instantly share code, notes, and snippets.

@spotlightishere
Created June 16, 2017 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spotlightishere/55d3091fabc098973531d6988b2fe6ef to your computer and use it in GitHub Desktop.
Save spotlightishere/55d3091fabc098973531d6988b2fe6ef to your computer and use it in GitHub Desktop.
This script went through an ics and converted it (by finding Discord users) and adding their IDs to yml. This will probably only be useful once lol
require_relative 'modules/settings.rb'
module SerieBot
require 'discordrb'
require 'yaml'
require 'fileutils'
require 'icalendar'
# Load helper as it is needed first.
helper_path = 'modules/helper.rb'
require_relative helper_path
puts "Loaded: #{helper_path}"
# Set up bot
if Config.appid == 0 || Config.appid.nil?
puts 'You need to set your app ID in config.rb!'
exit
end
bot = Discordrb::Commands::CommandBot.new token: Config.token, client_id: Config.appid, prefix: Config.prefix, parse_self: true, type: :bot
# Run Bot
Config.invite_url = bot.invite_url if Config.invite_url.nil?
puts "Invite URL #{Config.invite_url}"
bot.run :async
bot.online
bot.game = Config.playing
cal_file = File.open('birthdays.ics')
calendar = Icalendar::Calendar.parse(cal_file).first
yaml = Hash.new
# Go through each event
calendar.events.each do |event|
name = event.summary.gsub('\'s Birthday', '')
test = bot.find_user(name)[0]
if test
puts "Found #{test.distinct}'s user!"
date = event.dtstart
format = "#{date.month}-#{date.day}"
if yaml[format].nil?
yaml[format] = []
else
puts yaml[format]
end
# Add to IDs for that day
yaml[format] << test.id
else
puts "Couldn't find #{name}..."
end
end
puts yaml.to_yaml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment