Created
June 16, 2017 19:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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