Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions bytebot_config.py.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import os

BYTEBOT_STATUS_URL = 'http://status.bytespeicher.org/status.json'

BYTEBOT_HTTP_TIMEOUT = 3
BYTEBOT_HTTP_MAXSIZE = 1024 * 1024 * 10

BYTEBOT_PLUGIN_CONFIG = {
'rss': [
{
'name': 'Wiki',
'url': 'http://www.technikkultur-erfurt.de/feed.php',
'cache': '/tmp/feed_wiki.cache',
'type': 'dokuwiki',
},
{
'name': 'Website',
'url': 'https://bytespeicher.org/feed/',
'cache': '/tmp/feed_website.cache',
'type': 'wordpress',
},
{
'name': 'BytebotCommits',
'url': 'https://github.com/Bytespeicher/Bytebot/commits/master.atom',
'cache': '/tmp/feed_bytebot.cache',
'type': 'github',
},
{
'name': 'Redmine',
'url': 'http://redmine.bytespeicher.org/issues.atom',
'cache': '/tmp/feed_rm_bytespeicher.cache',
'type': 'redmine',
},
{
'name': 'SpacestatusCommits',
'url': 'https://github.com/Bytespeicher/space-status/commits/master.atom',
'cache': '/tmp/feed_spacestatus.cache',
'type': 'github'
},
],
'dates': {
'url': 'http://www.google.com/calendar/ical/2eskb61g20prl65k2qd01uktis%40group.calendar.google.com/public/basic.ics',
'timedelta': 21
},
'messagelogger': {
'file': '/tmp/irc.log'
},
'usercount': {
'file': '/tmp/irc_user.log'
},
'autoop': {
'name': {
'#channelname': [
'username',
],
},
'hostmask': {
'#channelname': [
'username!~user@example.com'
],
}
},
'spacestatus': {
'url': 'http://status.bytespeicher.org/status.json'
},
'ircquestions': {
'location': 'http://technikkultur-erfurt.de/bytespeicher:anfahrt',
'dates': 'http://technikkultur-erfurt.de/bytespeicher:veranstaltungen',
'versorgung': 'http://technikkultur-erfurt.de/bytespeicher:versorgung',
},
'shorturl': {
'shortener': 'krzus',
'api_key': 'thiswoudbeyourapikey',
'clarifai_app_id': 'yourappid',
'clarifai_app_secret': 'yourappsecret',
},
'parking': {
'url': 'parking_url',
},
'mensa': {
'canteen': 148,
},
'fuel': {
'apikey': 'thiswoudbeyourapikey',
'lat': '50.9827792',
'lng': '11.0394426',
'rad': '10',
},
'cccongress': {
'url': 'https://events.ccc.de/congress/YEAR/Fahrplan/schedule.json',
'cache': '/tmp/cccongress.cache',
'announce_minutes': 15,
},
'weather': {
'api_key': 'your_apikey',
'url': 'http://api.openweathermap.org/data/2.5/weather?units=metric&q=',
'location': 'city,countrycode'
},
'wikipedia': {
'url': 'https://de.wikipedia.org/w/api.php?&action=query&format=json&prop=extracts&exintro=&explaintext=&titles=',
'length_of_abstract': 400
},
'betterplace': {
'id': 24759,
},
}
53 changes: 53 additions & 0 deletions plugins/betterplace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from irc3.plugins.command import command

from bytebot_config import BYTEBOT_PLUGIN_CONFIG
from irc3 import asyncio
import aiohttp
import json


@command(permission="view")
@asyncio.coroutine
def betterplace(bot, mask, target, args):
"""Show the current betterplace projects

%%betterplace
"""
config = BYTEBOT_PLUGIN_CONFIG['betterplace']

if config['id'] == "betterplace_id":
return "I don't have your betterplace id!"

bot.privmsg(target, 'betterplace projects:')

try:
url = "https://api.betterplace.org/de/api_v4/organisations/" + \
str(config['id']) + \
"/projects.json"

with aiohttp.Timeout(10):
with aiohttp.ClientSession(loop=bot.loop) as session:
resp = yield from session.get(url)
if resp.status != 200:
bot.privmsg(
target, "Error while retrieving " + __name__ + " data")
raise Exception()
r = yield from resp.read()

projects = json.loads(r.decode('utf-8'))

for d in projects["data"]:
if(d["closed_at"] is None):
bot.privmsg(target,
" {name:35}" +
" {got:3}€ von {want:3}€ gespendet".format(
name=d["title"],
got=int(
d["donated_amount_in_cents"]) / 100,
want=int(d["donated_amount_in_cents"] +
d["open_amount_in_cents"]) / 100
))

except KeyError:
bot.privmsg(target, "Error while retrieving " + __name__ + " data")
raise Exception()