-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Notifies of scheduled events in iCal calendars. | ||
|
||
Depends on the libraries icalendar and requests. | ||
|
||
May limitless beings benefit. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
### | ||
# 2023, Matias Wilkman | ||
# | ||
# | ||
### | ||
|
||
""" | ||
Calendar: Notifies of scheduled events in iCal calendars | ||
""" | ||
|
||
import sys | ||
import supybot | ||
from supybot import world | ||
|
||
# Use this for the version of this plugin. | ||
__version__ = "0.1" | ||
|
||
__author__ = supybot.Author('Matias Wilkman', 'appas', | ||
'matias.wilkman@gmail.com') | ||
|
||
# This is a dictionary mapping supybot.Author instances to lists of | ||
# contributions. | ||
__contributors__ = {} | ||
|
||
# This is a url where the most recent plugin package can be downloaded. | ||
__url__ = 'https://github.com/matiasw/my-limnoria-plugins/Calendar' | ||
|
||
from . import config | ||
from . import plugin | ||
from importlib import reload | ||
# In case we're being reloaded. | ||
reload(config) | ||
reload(plugin) | ||
# Add more reloads here if you add third-party modules and want them to be | ||
# reloaded when this plugin is reloaded. Don't forget to import them as well! | ||
|
||
if world.testing: | ||
from . import test | ||
|
||
Class = plugin.Class | ||
configure = config.configure | ||
|
||
|
||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### | ||
# Copyright (c) 2023, Matias Wilkman | ||
# All rights reserved. | ||
# | ||
# | ||
### | ||
|
||
from supybot import conf, registry | ||
try: | ||
from supybot.i18n import PluginInternationalization | ||
_ = PluginInternationalization('Calendar') | ||
except: | ||
# Placeholder that allows to run the plugin on a bot | ||
# without the i18n module | ||
_ = lambda x: x | ||
|
||
|
||
def configure(advanced): | ||
# This will be called by supybot to configure this module. advanced is | ||
# a bool that specifies whether the user identified themself as an advanced | ||
# user or not. You should effect your configuration by manipulating the | ||
# registry as appropriate. | ||
from supybot.questions import expect, anything, something, yn | ||
conf.registerPlugin('Calendar', True) | ||
|
||
|
||
Calendar = conf.registerPlugin('Calendar') | ||
# This is where your configuration variables (if any) should go. For example: | ||
# conf.registerGlobalValue(Calendar, 'someConfigVariableName', | ||
# registry.Boolean(False, _("""Help for someConfigVariableName."""))) | ||
conf.registerGlobalValue(Calendar, 'calendars', | ||
registry.SpaceSeparatedListOfStrings("", """Determines the calendar URLs in (in ics format) to use""")) | ||
|
||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Stub so local is a module, used for third-party modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
### | ||
# 2023, Matias Wilkman | ||
# | ||
# | ||
### | ||
|
||
from supybot import utils, plugins, ircutils, callbacks | ||
from supybot.commands import * | ||
from supybot.i18n import PluginInternationalization | ||
from datetime import datetime | ||
import icalendar | ||
import requests | ||
|
||
_ = PluginInternationalization('Calendar') | ||
|
||
class Calendar(callbacks.Plugin): | ||
"""Notifies of scheduled events in iCal calendars""" | ||
threaded = True | ||
|
||
|
||
@wrap | ||
def nextevent(self, irc, msg, args): | ||
"""takes no arguments | ||
Replies with the next event in the calendar | ||
""" | ||
calendar = icalendar.Calendar.from_ical(requests.get(self.registryValue("calendars")[0]).text) | ||
for event in calendar.walk("VEVENT"): | ||
date = icalendar.vDDDTypes.from_ical(event.get("DTSTART")) | ||
if date > datetime.now().date(): | ||
reply = "The next event in the calendar is {summary}, on {date}".format( | ||
summary=event.get("SUMMARY"), | ||
date=date.strftime("%d.%m.%Y")) | ||
irc.reply(reply) | ||
|
||
Class = Calendar | ||
|
||
|
||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
### | ||
# Copyright (c) 2023, Matias Wilkman | ||
# All rights reserved. | ||
# | ||
# | ||
### | ||
|
||
from supybot.setup import plugin_setup | ||
|
||
plugin_setup( | ||
'Calendar', | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
### | ||
# Copyright (c) 2023, Matias Wilkman | ||
# All rights reserved. | ||
# | ||
# | ||
### | ||
|
||
from supybot.test import * | ||
|
||
|
||
class CalendarTestCase(PluginTestCase): | ||
plugins = ('Calendar',) | ||
|
||
|
||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: |