use of com.google.api.services.calendar.Calendar in project DisCal-Discord-Bot by NovaFox161.
the class EventMessageFormatter method getEventEmbed.
/**
* Gets an EmbedObject for the specified event.
*
* @param event The event involved.
* @param settings The guild's settings
* @return The EmbedObject of the event.
*/
public static EmbedObject getEventEmbed(Event event, GuildSettings settings) {
EventData ed = DatabaseManager.getManager().getEventData(settings.getGuildID(), event.getId());
EmbedBuilder em = new EmbedBuilder();
em.withAuthorIcon(Main.client.getGuildByID(266063520112574464L).getIconURL());
em.withAuthorName("DisCal");
em.withTitle(MessageManager.getMessage("Embed.Event.Info.Title", settings));
if (ed.getImageLink() != null && ImageUtils.validate(ed.getImageLink())) {
em.withImage(ed.getImageLink());
}
if (event.getSummary() != null) {
String summary = event.getSummary();
if (summary.length() > 250) {
summary = summary.substring(0, 250);
summary = summary + " (continues on Google Calendar View)";
}
em.appendField(MessageManager.getMessage("Embed.Event.Info.Summary", settings), summary, true);
}
if (event.getDescription() != null) {
String description = event.getDescription();
if (description.length() > 500) {
description = description.substring(0, 500);
description = description + " (continues on Google Calendar View)";
}
em.appendField(MessageManager.getMessage("Embed.Event.Info.Description", settings), description, true);
}
em.appendField(MessageManager.getMessage("Embed.Event.Info.StartDate", settings), getHumanReadableDate(event.getStart(), settings, false), true);
em.appendField(MessageManager.getMessage("Embed.Event.Info.StartTime", settings), getHumanReadableTime(event.getStart(), settings, false), true);
em.appendField(MessageManager.getMessage("Embed.Event.Info.EndDate", settings), getHumanReadableDate(event.getEnd(), settings, false), true);
em.appendField(MessageManager.getMessage("Embed.Event.Info.EndTime", settings), getHumanReadableTime(event.getEnd(), settings, false), true);
try {
// TODO: add support for multiple calendars...
CalendarData data = DatabaseManager.getManager().getMainCalendar(settings.getGuildID());
Calendar service;
service = settings.useExternalCalendar() ? CalendarAuth.getCalendarService(settings) : CalendarAuth.getCalendarService();
String tz = service.calendars().get(data.getCalendarAddress()).execute().getTimeZone();
em.appendField(MessageManager.getMessage("Embed.Event.Info.TimeZone", settings), tz, true);
} catch (Exception e1) {
em.appendField(MessageManager.getMessage("Embed.Event.Info.TimeZone", settings), "Error/Unknown", true);
}
if (event.getLocation() != null && !event.getLocation().equalsIgnoreCase("")) {
if (event.getLocation().length() > 300) {
String location = event.getLocation().substring(0, 300).trim() + "... (cont. on Google Cal)";
em.appendField(MessageManager.getMessage("Embed.Event.Confirm.Location", settings), location, true);
} else {
em.appendField(MessageManager.getMessage("Embed.Event.Confirm.Location", settings), event.getLocation(), true);
}
}
// TODO: Add info on recurrence here.
em.withUrl(event.getHtmlLink());
em.withFooterText(MessageManager.getMessage("Embed.Event.Info.ID", "%id%", event.getId(), settings));
try {
EventColor ec = EventColor.fromId(Integer.valueOf(event.getColorId()));
em.withColor(ec.getR(), ec.getG(), ec.getB());
} catch (Exception e) {
// Color is null, ignore and add our default.
em.withColor(56, 138, 237);
}
return em.build();
}
use of com.google.api.services.calendar.Calendar in project drbookings by DrBookings.
the class RunnableImportGoogleCalendar method process.
@Override
protected List<Booking> process(final IProgressMonitor monitor) throws Exception {
try {
if (logger.isInfoEnabled()) {
logger.info("Adding from " + url);
}
// initialize the transport
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
// initialize the data store factory
dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
// authorization
final Credential credential = authorize();
// set up global Calendar instance
final Calendar client = new com.google.api.services.calendar.Calendar.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName("drbookings").build();
final CalendarList list = client.calendarList().list().execute();
String id = null;
for (final CalendarListEntry item : list.getItems()) {
if (item.getSummary().contains("airbnb")) {
id = item.getId();
}
}
final Events feed = client.events().list(id).execute();
final List<Booking> result = new ArrayList<>();
for (final Event item : feed.getItems()) {
System.out.println(item);
result.add(new BookingBean(item.getSummary(), LocalDate.parse(item.getStart().getDate().toString()), LocalDate.parse(item.getEnd().getDate().toString())));
}
return result;
} finally {
monitor.done();
}
}
use of com.google.api.services.calendar.Calendar in project Saber-Bot by notem.
the class CalendarConverter method importCalendar.
/**
* Purges a schedule from entries and adds events (after conversion)
* from the next 7 day span of a Google Calendar
* @param address (String) valid address of calendar
* @param channel (MessageChannel) channel to sync with
* @param service connected calendar service with user credentials
*/
public void importCalendar(String address, TextChannel channel, Calendar service) {
// sanity checks
if (channel == null || address == null)
return;
if (!Main.getScheduleManager().isASchedule(channel.getId()))
return;
// query the google calendar address for the list of events
Events events;
try {
ZonedDateTime min = ZonedDateTime.now();
ZonedDateTime max = min.plusDays(Main.getScheduleManager().getSyncLength(channel.getId()));
events = service.events().list(address).setTimeMin(new DateTime(min.format(EventRecurrence.RFC3339_FORMATTER))).setTimeMax(new DateTime(max.format(EventRecurrence.RFC3339_FORMATTER))).setOrderBy("startTime").setSingleEvents(true).setMaxResults(Main.getBotSettingsManager().getMaxEntries()).execute();
} catch (Exception e) {
Logging.exception(this.getClass(), e);
return;
}
try // convert the list of Google Events into discord event entries
{
// send 'is typing' while the sync is in progress
channel.sendTyping().queue();
/* lock the schedule for syncing; schedule is unlocked in finally block */
Main.getScheduleManager().lock(channel.getId());
// change the zone to match the calendar
// only if the zone has not been manually set for that schedule
ZoneId zone = ZoneId.of(events.getTimeZone());
Boolean syncZone = Main.getDBDriver().getScheduleCollection().find(eq("_id", channel.getId())).first().getBoolean("timezone_sync", false);
if (syncZone) {
Main.getScheduleManager().setTimeZone(channel.getId(), zone);
}
// a set of all unique (not child of a recurring event) events
HashSet<String> uniqueEvents = new HashSet<>();
// process events
for (Event event : events.getItems()) {
// continue to send 'is typing'
channel.sendTyping().queue();
// if the unique google event ID does not appear in the already processed events
// convert the event and add it to the schedule
String recurrenceId = event.getRecurringEventId();
String googleId = recurrenceId == null ? event.getId() : recurrenceId;
if (!uniqueEvents.contains(googleId)) {
// declare and initialize event parameters
ZonedDateTime start, end;
String title;
ArrayList<String> comments = new ArrayList<>();
int repeat = 0;
ZonedDateTime expire = null;
String imageUrl = null;
String thumbnailUrl = null;
ZonedDateTime rsvpDeadline = null;
String titleUrl = null;
Map<String, Integer> rsvpLimits = new HashMap<>();
if (event.getStart().getDateTime() == null) {
/* parse start and end dates for all day events */
start = ZonedDateTime.of(LocalDate.parse(event.getStart().getDate().toStringRfc3339()), LocalTime.MIN, zone);
end = ZonedDateTime.of(LocalDate.parse(event.getEnd().getDate().toStringRfc3339()), LocalTime.MIN, zone);
} else {
/* parse start and end times for normal events */
start = ZonedDateTime.parse(event.getStart().getDateTime().toStringRfc3339(), EventRecurrence.RFC3339_FORMATTER).withZoneSameInstant(zone);
end = ZonedDateTime.parse(event.getEnd().getDateTime().toStringRfc3339(), EventRecurrence.RFC3339_FORMATTER).withZoneSameInstant(zone);
}
// get event title
if (event.getSummary() == null)
title = "(No title)";
else
title = event.getSummary();
// process event description into event comments or other settings
if (event.getDescription() != null) {
// process the description line by line
String description = HTMLStripper.cleanDescription(event.getDescription().replace("\n", "<br>"));
for (String comment : description.split("\n")) {
comment = comment.trim();
String lowerCase = comment.toLowerCase();
// image
if (lowerCase.startsWith("image:")) {
// split to limit:
String[] tmp = comment.split(":", 2);
if (tmp.length > 1) {
imageUrl = tmp[1].trim().replaceAll(" ", "");
if (!VerifyUtilities.verifyUrl(imageUrl))
imageUrl = null;
}
} else // thumbnail
if (lowerCase.startsWith("thumbnail:")) {
String[] tmp = comment.split(":", 2);
if (tmp.length > 1) {
thumbnailUrl = tmp[1].trim().trim().replaceAll(" ", "");
if (!VerifyUtilities.verifyUrl(thumbnailUrl))
thumbnailUrl = null;
}
} else // limit
if (lowerCase.startsWith("limit:")) {
// split to limit:
String[] tmp = comment.split(":", 2);
if (tmp.length > 1) {
// split into white space separated segments
String[] str = tmp[1].trim().split("[^\\S\n\r]+");
if (str.length >= 2) {
// rebuild the rsvp group name
StringBuilder name = new StringBuilder();
for (int i = 0; i < str.length - 1; i++) {
name.append(str[i]);
if (i != str.length - 2)
name.append(" ");
}
// parse the limit
Integer limit = -1;
if (VerifyUtilities.verifyInteger(str[str.length - 1]))
limit = Integer.parseInt(str[str.length - 1]);
rsvpLimits.put(name.toString(), limit);
}
}
} else // title url
if (lowerCase.startsWith("url:")) {
String[] tmp = comment.split(":", 2);
if (tmp.length > 1 && VerifyUtilities.verifyUrl(tmp[1].trim().replaceAll(" ", "")))
titleUrl = tmp[1].trim().replaceAll(" ", "");
} else // deadline
if (lowerCase.startsWith("deadline:")) {
String tmp = lowerCase.replace("deadline:", "").trim().replaceAll(" ", "");
if (VerifyUtilities.verifyDate(tmp))
rsvpDeadline = ParsingUtilities.parseDate(tmp, zone);
} else // plaintext comment
if (!comment.trim().isEmpty()) {
comments.add(comment);
}
}
}
// get the event recurrence information
List<String> recurrence = event.getRecurrence();
if (recurrenceId != null)
recurrence = service.events().get(address, recurrenceId).execute().getRecurrence();
// parse the event recurrence information
if (recurrence != null) {
// determine the start date
ZonedDateTime dtStart = // if orig is null, use start
event.getOriginalStartTime() == null ? // if orig is null, use start
start : (event.getOriginalStartTime().getDateTime() == null ? start : ZonedDateTime.parse(event.getOriginalStartTime().getDateTime().toStringRfc3339(), EventRecurrence.RFC3339_FORMATTER).withZoneSameInstant(zone));
EventRecurrence eventRecurrence = new EventRecurrence(recurrence, dtStart);
expire = eventRecurrence.getExpire();
repeat = eventRecurrence.getRepeat();
}
// if the google event already exists as a saber event on the schedule, update it
// otherwise add as a new saber event
Document doc = Main.getDBDriver().getEventCollection().find(and(eq("channelId", channel.getId()), eq("googleId", googleId))).first();
// should the event be flagged as already started?
boolean hasStarted = start.isBefore(ZonedDateTime.now());
if (doc != null && (new ScheduleEntry(doc)).getMessageObject() != null) {
/* update an existing event */
ScheduleEntry se = (new ScheduleEntry(doc)).setTitle(title).setStart(start).setEnd(end).setRepeat(repeat).setGoogleId(googleId).setExpire(expire).setStarted(hasStarted).setComments(comments).setLocation(event.getLocation());
// set special attributes if not null
if (titleUrl != null)
se.setTitleUrl(titleUrl);
if (imageUrl != null)
se.setImageUrl(imageUrl);
if (thumbnailUrl != null)
se.setThumbnailUrl(thumbnailUrl);
if (rsvpDeadline != null)
se.setRsvpDeadline(rsvpDeadline);
if (rsvpLimits.keySet().size() > 0)
se.setRsvpLimits(rsvpLimits);
// update event reminders using schedule default settings
se.reloadReminders(Main.getScheduleManager().getReminders(se.getChannelId())).reloadEndReminders(Main.getScheduleManager().getEndReminders(se.getChannelId())).regenerateAnnouncementOverrides();
Main.getEntryManager().updateEntry(se, false);
} else {
/* create a new event */
ScheduleEntry se = (new ScheduleEntry(channel, title, start, end)).setTitleUrl(titleUrl != null ? titleUrl : event.getHtmlLink()).setRepeat(repeat).setGoogleId(googleId).setExpire(expire).setStarted(hasStarted).setComments(comments).setLocation(event.getLocation());
// set special attributes if not null
if (imageUrl != null)
se.setImageUrl(imageUrl);
if (thumbnailUrl != null)
se.setThumbnailUrl(thumbnailUrl);
if (rsvpDeadline != null)
se.setRsvpDeadline(rsvpDeadline);
if (rsvpLimits.keySet().size() > 0)
se.setRsvpLimits(rsvpLimits);
Main.getEntryManager().newEntry(se, false);
}
// add to google ID to unique event mapping
uniqueEvents.add(recurrenceId == null ? event.getId() : recurrenceId);
}
}
// purge channel of all entries on schedule that aren't in uniqueEvents
Bson query = and(eq("channelId", channel.getId()), nin("googleId", uniqueEvents));
Main.getDBDriver().getEventCollection().find(query).forEach((Consumer<? super Document>) document -> {
ScheduleEntry entry = Main.getEntryManager().getEntry((Integer) document.get("_id"));
Message msg = entry.getMessageObject();
if (msg == null)
return;
Main.getEntryManager().removeEntry((Integer) document.get("_id"));
MessageUtilities.deleteMsg(msg, null);
});
// set channel topic
JDA jda = Main.getShardManager().getJDA(channel.getGuild().getId());
String calLink = "https://calendar.google.com/calendar/embed?src=" + address;
boolean hasPerms = channel.getGuild().getMember(jda.getSelfUser()).hasPermission(channel, Permission.MANAGE_CHANNEL);
if (hasPerms)
channel.getManagerUpdatable().getTopicField().setValue(calLink).update().queue();
} catch (Exception e) {
Logging.exception(this.getClass(), e);
} finally {
// syncing done, unlock the channel
Main.getScheduleManager().unlock(channel.getId());
}
// auto-sort
EntryManager.autoSort(true, channel.getId());
}
use of com.google.api.services.calendar.Calendar in project Saber-Bot by notem.
the class CalendarConverter method init.
public void init() {
try {
// Build a new authorized API client service.
// Note: Do not confuse this class with the
// com.google.api.services.calendar.model.Calendar class.
// if this fails, do not enable schedule synchronization
Calendar service = GoogleAuth.getCalendarService(GoogleAuth.authorize());
// enable the sync command
Main.getCommandHandler().putSync();
// start the schedule sync timer
Main.getScheduleManager().initScheduleSync();
} catch (IOException e) {
Logging.warn(this.getClass(), e.getMessage());
} catch (Exception e) {
Logging.exception(this.getClass(), e);
}
}
use of com.google.api.services.calendar.Calendar in project Saber-Bot by notem.
the class ConfigCommand method verify.
@Override
public String verify(String prefix, String[] args, MessageReceivedEvent event) {
String cmd = prefix + this.name();
int index = 0;
if (args.length < 1) {
return "That's not enough arguments! Use ``" + cmd + " <channel> [<option> <new config>]``";
}
String cId = args[index].replaceAll("[^\\d]", "");
if (!Main.getScheduleManager().isASchedule(cId)) {
return "Channel " + args[index] + " is not on my list of schedule channels for your guild. " + "Use the ``" + prefix + "init`` command to create a new schedule!";
}
if (Main.getScheduleManager().isLocked(cId)) {
return "Schedule is locked while sorting/syncing. Please try again after sort/sync finishes.";
}
index++;
if (args.length > 1) {
if (args.length < 2) {
return "That's not enough arguments! Use ``" + cmd + " <channel> [<option> <new config>]``";
}
Set<Integer> list = null;
switch(args[index++].toLowerCase()) {
case "m":
case "msg":
case "message":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] message <new config>]``, " + "where ``<new config>`` is the message format string to use when create announcement and remind messages.\n" + "Reference the ``info`` command information for ``config`` to learn more about custom announcement messages.";
}
break;
case "ch":
case "chan":
case "channel":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] channel <new config>``, " + "where ``<new config>`` is a discord channel to which announcement messages should be sent.\n";
}
break;
case "em":
case "end-msg":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] end-msg <new config>``, " + "where ``<new config>`` is the message format string to use when create event end messages.\n" + "This overrides the ``[message]`` setting for events which are ending.\n" + "Reference the ``info`` command information for ``config`` to learn more about custom announcement messages.";
}
break;
case "ech":
case "end-chan":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] end-chan <new config>``, " + "where <new config> is a discord channel to which event end messages should be sent.\n" + "This overrides the ``[channel]`` setting for events which are ending.";
}
break;
case "z":
case "zone":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] zone <new config>``, where ``<new config>`` is a valid timezone string." + "\nA list of valid timezones can be seen using the ``zones`` command).";
}
if (!VerifyUtilities.verifyZone(args[index])) {
return "**" + args[index] + "** is not a valid timezone! Use the ``zones`` command to learn " + "what options are available.";
}
break;
case "cl":
case "clock":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] clock <new config>``, " + "where ``<new config>`` is **\"12\"** for 12 hour format (am/pm), or **\"24\"** for full 24 hour time.";
}
if (!args[index].equals("24") && !args[index].equals("12")) {
return "Argument **" + args[index] + "** is not a valid option. Argument must be **24** " + "or **12**";
}
break;
case "sy":
case "sync":
// get user Google credentials (if they exist)
Credential credential = GoogleAuth.getCredential(event.getAuthor().getId());
if (credential == null) {
return "I failed to connect to Google API Services!";
}
Calendar service = GoogleAuth.getCalendarService(credential);
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] sync <new config>``, " + "where ``<new config>`` is a google calendar address or **\"off\"**";
}
if (args[index].equalsIgnoreCase("off")) {
return "";
}
if (!Main.getCalendarConverter().checkValidAddress(args[index], service)) {
return "I cannot sync to **" + args[index] + "**!";
}
break;
case "t":
case "time":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#channel] time <new config>``, " + "where ``<new config>`` is the time of day to which the schedule should be automatically " + "resync to the linked google calendar address.";
}
if (!VerifyUtilities.verifyTime(args[index])) {
return "I cannot parse ``" + args[index] + "`` into a time!";
}
break;
case "er":
case "end-remind":
case "end-reminder":
case "end-reminders":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " " + args[0] + " end-reminder [add|remove] [reminder]``, " + "where ``[reminder]`` is the number of minutes before the event starts " + "that the reminder should be sent.";
}
list = new LinkedHashSet<>();
list.addAll(Main.getScheduleManager().getReminders(cId));
// verification of end-remind input is the same as remind
case "r":
case "remind":
case "reminder":
case "reminders":
if (list == null) {
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " " + args[0] + " reminder [add|remove] [reminder]``, " + "where ``[reminder]`` is the number of minutes before the event starts " + "that the reminder should be sent.";
}
list = new LinkedHashSet<>();
list.addAll(Main.getScheduleManager().getReminders(cId));
}
switch(args[index]) {
case "off":
return "";
case "add":
if (args.length < 4) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " " + args[0] + " reminder " + args[index] + " [reminder]``, " + "where ``[reminder]`` is the number of minutes before the event starts " + "that the reminder should be sent.";
}
index++;
list.addAll(ParsingUtilities.parseReminder(args[index]));
if (list.size() <= 0)
return "I could not parse out any times!";
break;
case "remove":
if (args.length < 4) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " " + args[0] + " reminder " + args[index] + " [reminder]``, " + "where ``[reminder]`` is the number of minutes before the event starts " + "that the reminder should be sent.";
}
index++;
list.removeAll(ParsingUtilities.parseReminder(args[index]));
break;
default:
list = ParsingUtilities.parseReminder(args[index]);
if (list.size() <= 0)
return "I could not parse out any times!";
break;
}
if (list.size() > 20) {
return "More than 20 reminders are not allowed!";
}
for (int reminder : list) {
if (reminder < 5)
return "Reminders must not less than 5 minutes!";
}
break;
case "rm":
case "rem-msg":
case "remind-msg":
case "remind-message":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [chan] remind-msg <new config>``, " + "where ``<new config>`` is the message format string to use when sending remind messages.\n" + "This setting will override the ``[msg]`` option for reminders.\n" + "Reference the ``info`` command information for ``config`` to learn more about custom announcement messages.";
}
break;
case "rch":
case "rem-chan":
case "remind-chan":
case "remind-channel":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [chan] remind-chan <new config>``, " + "where ``<new config>`` is a discord channel to which announcement messages should be sent.\n";
}
break;
case "rsvp":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [chan] rsvp <new config>``, " + "where <new config> should be \"on\" to enable the rsvp feature, or \"off\" to " + "disable the feature.\n";
}
switch(args[index]) {
case "add":
case "a":
index++;
if (args.length != 5) {
return "Argument *" + args[index - 1] + "* is not properly formed for the ``add`` option!\n" + "Use ``" + cmd + " [#channel] rsvp add [name] [emoji]`` to add a new rsvp option " + "where [emoji] is the discord emoji for the rsvp option to use and " + "[name] is the display name of the rsvp option.";
}
// verify input is either a valid unicode emoji or discord emoji
if (!VerifyUtilities.verifyEmoji(args[index + 1])) {
return "*" + args[index + 1] + "* is not an emoji!\n" + "Your emoji must be a valid unicode emoji or custom discord emoji!";
}
if (Main.getScheduleManager().getRSVPOptions(cId).values().contains(args[index].trim())) {
return "RSVP group name *" + args[index] + "* already exists!\n" + "Please choose a different name for your rsvp group!";
}
break;
case "remove":
case "r":
index++;
if (args.length != 4) {
return "Argument *" + args[index - 1] + "* is not properly formed for the ``add`` option!\n" + "Use ``" + cmd + " [#channel] rsvp remove [name]`` to remove a rsvp option " + "where [name] is the display name of the rsvp option.";
}
break;
case "off":
case "on":
case "true":
case "false":
break;
default:
{
return "Argument *" + args[index] + "* is not an appropriate argument!\n" + "Use ``" + cmd + " [#channel] rsvp [on|off]`` to enable/disable rsvp on the schedule.\n" + "Use ``" + cmd + " [#channel] rsvp add [emoji]-[name]`` to add a new rsvp option.\n" + "Use ``" + cmd + " [#channel] rsvp remove [emoji|name]`` to remove an rsvp option.";
}
}
break;
case "clear":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#chan] clear <emoji>``, " + "where ``<emoji>`` is the discord emoji to use for the rsvp clear function.\n";
}
if (!VerifyUtilities.verifyEmoji(args[index])) {
switch(args[index]) {
case "off":
break;
default:
return "*" + args[index] + "* is not an emoji!\n" + "Your clear emoji must be a valid unicode emoji or custom discord emoji!";
}
}
Set<String> keys = Main.getScheduleManager().getRSVPOptions(cId).keySet();
if (keys.contains(args[index].trim()) || keys.contains(args[index].replaceAll("[^\\d]", ""))) {
return "RSVP group name *" + args[index] + "* already exists!\n" + "Please choose a different name for your rsvp clear option!";
}
break;
case "co":
case "confirm":
case "confirmation":
case "confirmations":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#chan] confirmation <on|off>`` to enable/disable confirmation DMs on rsvp actions.";
}
switch(args[index].toLowerCase()) {
case "yes":
case "no":
case "false":
case "true":
case "on":
case "off":
break;
default:
return "RSVP confirmations should be either *on* or *off*!";
}
break;
case "ex":
case "exclude":
case "exclusivity":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#chan] exclusivity <on|off>`` to configure rsvp exclusivity.";
}
switch(args[index].toLowerCase()) {
case "yes":
case "no":
case "false":
case "true":
case "on":
case "off":
break;
default:
return "RSVP exclusivity should be either *on* or *off*!";
}
break;
case "log":
case "logging":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [#chan] logging <off|#channel>`` to configure rsvp logging.";
}
break;
case "st":
case "style":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [chan] style <new config>``, " + "where ``<new config>`` can either be **\"full\"** to display events in the lengthy full information style, or **\"narrow\"** to " + "to display events in a compressed, smaller style.\n";
}
break;
case "l":
case "len":
case "length":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [chan] length <new config>``, " + "where ``<new config>`` is the length of time (in days) to which the linked google " + "calendar should be synced.\nFor example, \"7\" will sync a weeks worth events to " + "the schedule and \"365\" will have the schedule display the full month of events.";
}
if (!VerifyUtilities.verifyInteger(args[index])) {
return "*" + args[index] + "*" + " is not an integer!\n This option takes a ";
}
Integer len = Integer.parseInt(args[index]);
if (len > 365 || len < 1) {
return "The sync length must be number between 1 and 365!";
}
break;
case "so":
case "sort":
if (args.length < 3) {
return "That's not enough arguments!\n" + "Use ``" + cmd + " [chan] sort <new config>``, " + "where ``<new config>`` may be either **\"asc\"** to automatically sort the schedule in ascending order," + " **\"desc\"** for descending order, or **\"off\"** to disable auto-sorting.";
}
switch(args[index]) {
case "disabled":
case "off":
case "desc":
case "asc":
case "ascending":
case "descending":
return "";
default:
return "*" + args[index] + "* is not a valid sort option! Use *off*, *desc*, or *asc*.";
}
default:
{
return "Argument **" + args[index - 1] + "** is not a configurable setting! Options are **message**, " + "**channel**, **zone**, **clock**, **sync**, **time**, and **remind**.";
}
}
}
return "";
}
Aggregations