Compare commits

...
This repository has been archived on 2023-04-13. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.

57 commits

Author SHA1 Message Date
ChChBot admin
358b415566 added corridor light 2017-11-30 22:24:15 +01:00
ChChBot admin
3e1ea6ac4e fixed command names 2017-03-13 23:46:44 +01:00
ChChBot admin
48b627ad4b Merge branch 'ChaosChemnitz' of https://git.chch.it/ChCh/CloudBot_github into ChaosChemnitz 2017-03-13 23:32:29 +01:00
ChChBot admin
1f1ff649c9 deactivated unused functions 2017-03-13 23:31:52 +01:00
8344fe7693 implemented light commands for e-lab 2017-03-13 23:22:15 +01:00
a6992d5d1a Merge branch 'ChaosChemnitz' of vcup.florz.net:/home/cloudbot/CloudBot into ChaosChemnitz 2017-02-24 22:21:33 +01:00
ChChBot admin
21db4efd98 implemented lounge_light command 2017-02-24 22:20:30 +01:00
ChChBot admin
8941d59dc2 removed buggy part for killing old processes 2017-02-24 17:08:01 +01:00
09ce708709 Merge branch 'ChaosChemnitz' of vcup.florz.net:/home/cloudbot/CloudBot into ChaosChemnitz 2017-02-23 00:46:13 +01:00
ChChBot admin
29cc95f0ad Merge branch 'ChaosChemnitz' of https://git.chch.it/ChCh/CloudBot_github into ChaosChemnitz
Conflicts:
	plugins/chch_worker.py
2017-02-23 00:41:05 +01:00
4a02f545ea Merge branch 'ChaosChemnitz' of github.com:ChaosChemnitz/CloudBot into ChaosChemnitz 2017-02-23 00:35:13 +01:00
ChChBot admin
28176ad2ad added new feature to toggle lounge light 2017-02-23 00:18:23 +01:00
ChChBot admin
651d4a953e fork and disown start script 2017-02-22 23:45:52 +01:00
ChChBot admin
80711e1278 changed IP to localhost 2017-02-22 23:45:32 +01:00
a88d5ef0bd Merge pull request #4 from marenz2569/ChaosChemnitz
command lamp_lounge: UDP -> TCP
2017-01-12 10:17:45 +01:00
827c5c73e8 command lamp_lounge: UDP -> TCP 2017-01-11 21:29:01 +01:00
ChChBot admin
580415ed76 Merge branch 'ChaosChemnitz' of https://git.chch.it/ChCh/CloudBot_github into ChaosChemnitz 2016-11-17 21:40:48 +01:00
c562a2c7ae Merge branch 'ChaosChemnitz' of github.com:ChaosChemnitz/CloudBot into ChaosChemnitz 2016-11-17 21:32:54 +01:00
ChChBot admin
4b5e86c237 ignore config.ssl 2016-11-17 21:24:07 +01:00
txt.file
11687a9ad0 Merge pull request #3 from marenz2569/ChaosChemnitz
Fensterbogenbeleuchtungssteuerung
2016-11-17 19:18:48 +00:00
296de07e14 uncommented event 332 2016-11-17 19:53:00 +01:00
dfbead6946 added command for controlling the fensterbogenbeleuchtung in the lounge (lamp_lounge) 2016-11-17 19:50:06 +01:00
root
e30eca5ebd old changes + fixed utf8 problems 2016-02-04 16:55:03 +01:00
root
2a3c9f52dc added logging to syslog 2016-02-04 16:53:15 +01:00
ChChBot admin
f88c3267d4 created reverse SSH tunnel for light control 2015-02-21 20:11:56 +01:00
ChChBot admin
2b18eaac5a Revert "disable chch_worker"
This reverts commit 05bfb9099a.
2015-02-20 13:13:45 +01:00
0650046d18 Merge branch 'ChaosChemnitz' of https://github.com/Stummi/CloudBot into ChaosChemnitz 2015-02-19 22:14:13 +01:00
Michael Stummvoll
4e386c9008 update default config 2015-02-19 17:22:27 +01:00
Michael Stummvoll
05bfb9099a disable chch_worker 2015-02-19 17:20:59 +01:00
Michael Stummvoll
bfa3fb6e74 move version check into own plugin 2015-02-19 17:20:35 +01:00
Florian Schlegel
d415d0fc69 Merge pull request #2 from ChaosChemnitz/revert-1-ChaosChemnitz
Revert "add ctcp version check and kick the logbot clients"
2015-02-19 16:22:32 +01:00
Florian Schlegel
433d97d276 Revert "add ctcp version check and kick the logbot clients" 2015-02-19 16:21:14 +01:00
Florian Schlegel
121715115a Merge pull request #1 from Stummi/ChaosChemnitz
add ctcp version check and kick the logbot clients
2015-02-19 14:06:57 +01:00
Michael Stummvoll
620de651ce add ctcp version check and kick the logbot clients 2015-02-19 13:59:27 +01:00
ChChBot admin
3f205eaafa simple restart script to keep the bot alive 2015-02-18 23:01:52 +01:00
ChChBot admin
59cd8380d2 some changes... 2015-02-18 22:55:28 +01:00
ChChBot admin
7cce9bf27e disabled many plugins 2015-02-18 22:53:13 +01:00
ChChBot admin
0ba2001b62 some new plugins (thx to _20h_) 2015-02-18 22:49:44 +01:00
Morris Jobke
63fc042027 add plugin for topic update with status 2014-04-05 12:27:28 +02:00
Luke Rogers
9421d8160d Merge pull request #224 from daboross/patch-3
Create config.default that was removed
2014-04-04 14:11:33 +13:00
Dabo Ross
4b4ac2d918 Create config.default that was removed
1062e69e56 ?
2014-04-03 09:29:09 -07:00
Luke Rogers
05a68faf1d tidied 2014-04-03 19:44:38 +13:00
Luke Rogers
40328cf24f Merge remote-tracking branch 'origin/develop' into develop 2014-04-03 18:27:42 +13:00
Luke Rogers
fb471bee17 Added random output, switched API URL 2014-04-03 18:27:17 +13:00
Luke Rogers
48ab7417b8 Update recipe.py 2014-04-03 15:01:19 +13:00
Luke Rogers
97a3283eff Switched suggest API 2014-04-02 23:22:39 +13:00
Luke Rogers
6d147e1677 Stuff 2014-04-02 20:12:21 +13:00
Luke Rogers
c99c44616c Adapted code to get multiple results! 2014-04-02 20:08:56 +13:00
Luke Rogers
1062e69e56 Strip spaces 2014-04-02 20:03:14 +13:00
Luke Rogers
5ca45fea4b Added recipe searching! 2014-04-02 15:03:10 +13:00
Luke Rogers
04af154c5b Added more features! 2014-04-01 19:43:03 +13:00
Luke Rogers
f82041fc87 Merge branch 'develop' of https://github.com/ClouDev/CloudBot into develop 2014-04-01 17:58:00 +13:00
Luke Rogers
a027bd780f Added fancy new recipe plugin! 2014-04-01 17:57:39 +13:00
Luke Rogers
a611e0df45 Merge pull request #221 from daboross/fix-dictionary-unicode-support
Fix unicode support for dictionary.py
2014-03-31 20:58:10 +13:00
Luke Rogers
e49ec9a9c9 Merge pull request #218 from daboross/fix-wiki-unicode-support
Fix unicode support for wikipedia
2014-03-31 20:58:09 +13:00
Dabo Ross
4652ed90a3 Fix unicode support for wikipedia 2014-03-28 18:15:39 -07:00
Dabo Ross
ff3ef576b7 Fix unicode support for dictionary.py 2014-03-27 10:30:30 -07:00
129 changed files with 803 additions and 133 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
persist
config
config.ssl
gitflow
*.db
*.log

View file

@ -1,64 +1,77 @@
{
"connections":
{
"esper":
{
"server": "irc.esper.net",
"nick": "MyCloudBot",
"user": "cloudbot",
"realname": "CloudBot - http://git.io/cloudbotirc",
"mode": "",
"nickserv_password": "",
"nickserv_user": "",
"channels": ["#cloudbot", "#cloudbot2"],
"invite_join": true,
"auto_rejoin": false,
"command_prefix": "."
}
},
"disabled_plugins": [],
"disabled_commands": [],
"acls": {},
"api_keys":
{
"tvdb": "",
"wolframalpha": "",
"lastfm": "",
"rottentomatoes": "",
"soundcloud": "",
"twitter_consumer_key": "",
"twitter_consumer_secret": "",
"twitter_access_token": "",
"twitter_access_secret": "",
"wunderground": "",
"googletranslate": "",
"rdio_key": "",
"rdio_secret": ""
},
"permissions": {
"admins": {
"perms": ["adminonly", "addfactoid", "delfactoid", "ignore", "botcontrol", "permissions_users", "op"],
"users": ["examplea!user@example.com", "exampleb!user@example.com"]
"connections": {
"hackint": {
"server": "irc.hackint.eu",
"nick": "antibot",
"user": "antibot",
"realname": "CloudBot - http://git.io/cloudbotirc",
"mode": "",
"_nickserv_password": "",
"-nickserv_user": "",
"channels": [
"#ChaosChemnitz",
"#logbot"
],
"invite_join": true,
"auto_rejoin": false,
"command_prefix": "."
}
},
"moderators": {
"perms": ["addfactoid", "delfactoid", "ignore"],
"users": ["examplec!user@example.com"]
}
},
"plugins":
{
"factoids":
{
"prefix": false
"disabled_plugins": [],
"disabled_commands": [],
"acls": {},
"api_keys": {
"tvdb": "",
"wolframalpha": "",
"lastfm": "",
"rottentomatoes": "",
"soundcloud": "",
"twitter_consumer_key": "",
"twitter_consumer_secret": "",
"twitter_access_token": "",
"twitter_access_secret": "",
"wunderground": "",
"googletranslate": "",
"rdio_key": "",
"rdio_secret": ""
},
"ignore":
{
"ignored": []
}
},
"censored_strings":
[
"mypass",
"mysecret"
]
"permissions": {
"admins": {
"perms": [
"adminonly",
"addfactoid",
"delfactoid",
"ignore",
"botcontrol",
"permissions_users",
"op"
],
"users": [
"examplea!user@example.com",
"exampleb!user@example.com"
]
},
"moderators": {
"perms": [
"addfactoid",
"delfactoid",
"ignore"
],
"users": [
"stummi!~Stummi@stummi.org"
]
}
},
"plugins": {
"factoids": {
"prefix": false
},
"ignore": {
"ignored": []
}
},
"censored_strings": [
"mypass",
"mysecret"
]
}

View file

@ -44,7 +44,16 @@ class crlf_tcp(object):
return socket.socket(socket.AF_INET, socket.TCP_NODELAY)
def run(self):
self.socket.connect((self.host, self.port))
noerror = 0
while 1:
try:
self.socket.connect((self.host, self.port))
break
except socket.gaierror as e:
time.sleep(5)
except socket.timeout as e:
time.sleep(5)
thread.start_new_thread(self.recv_loop, ())
thread.start_new_thread(self.send_loop, ())
@ -55,17 +64,25 @@ class crlf_tcp(object):
return socket.timeout
def handle_receive_exception(self, error, last_timestamp):
print("Receive exception: %s" % (error))
if time.time() - last_timestamp > self.timeout:
print("Receive timeout. Restart connection.")
self.iqueue.put(StopIteration)
self.socket.close()
return True
return False
def handle_send_exception(self, error):
print("Send exception: %s" % (error))
self.iqueue.put(StopIteration)
self.socket.close()
return True
def recv_loop(self):
last_timestamp = time.time()
while True:
try:
data = self.recv_from_socket(4096)
data = self.recv_from_socket(4096)
self.ibuffer += data
if data:
last_timestamp = time.time()
@ -79,6 +96,8 @@ class crlf_tcp(object):
if self.handle_receive_exception(e, last_timestamp):
return
continue
except AttributeError:
return
while '\r\n' in self.ibuffer:
line, self.ibuffer = self.ibuffer.split('\r\n', 1)
@ -86,13 +105,19 @@ class crlf_tcp(object):
def send_loop(self):
while True:
line = self.oqueue.get().splitlines()[0][:500]
print ">>> %r" % line
self.obuffer += line.encode('utf-8', 'replace') + '\r\n'
while self.obuffer:
sent = self.socket.send(self.obuffer)
self.obuffer = self.obuffer[sent:]
try:
line = self.oqueue.get().splitlines()[0][:500]
if line == StopIteration:
return
print ">>> %r" % line
self.obuffer += line.encode('utf-8', 'replace') + '\r\n'
while self.obuffer:
sent = self.socket.send(self.obuffer)
self.obuffer = self.obuffer[sent:]
except socket.error as e:
self.handle_send_exception(e)
return
class crlf_ssl_tcp(crlf_tcp):
"""Handles ssl tcp connetions that consist of utf-8 lines ending with crlf"""
@ -114,10 +139,13 @@ class crlf_ssl_tcp(crlf_tcp):
def handle_receive_exception(self, error, last_timestamp):
# this is terrible
if not "timed out" in error.args[0]:
raise
#if not "timed out" in error.args[0]:
# raise
return crlf_tcp.handle_receive_exception(self, error, last_timestamp)
def handle_send_exception(self, error):
return crlf_tcp.handle_send_exception(self, error)
irc_prefix_rem = re.compile(r'(.*?) (.*?) (.*)').match
irc_noprefix_rem = re.compile(r'()(.*?) (.*)').match

Binary file not shown.

View file

@ -19,10 +19,10 @@ def define(inp):
'//div[@class="example"]')
if not definition:
return 'No results for ' + inp + ' :('
return u'No results for {} :('.format(inp)
def format_output(show_examples):
result = '{}: '.format(h.xpath('//dt[@class="title-word"]/a/text()')[0])
result = u'{}: '.format(h.xpath('//dt[@class="title-word"]/a/text()')[0])
correction = h.xpath('//span[@class="correct-word"]/text()')
if correction:
@ -77,7 +77,7 @@ def etymology(inp):
etym = h.xpath('//dl')
if not etym:
return 'No etymology found for {} :('.format(inp)
return u'No etymology found for {} :('.format(inp)
etym = etym[0].text_content()

13
disabled_stuff/freddy.py Normal file
View file

@ -0,0 +1,13 @@
from util import hook, http, web
from subprocess import check_output, CalledProcessError
@hook.command
def freddycode(inp):
"""freddycode <code> - Check if the Freddy Fresh code is correct."""
try:
return "Freddy: '%s' ist %s" % (inp, \
check_output(["/bin/freddycheck", inp]))
except CalledProcessError as err:
return "Freddy: Skript returned %s" % (str(err))

106
disabled_stuff/recipe.py Normal file
View file

@ -0,0 +1,106 @@
import random
from util import hook, http, web
metadata_url = "http://omnidator.appspot.com/microdata/json/?url={}"
base_url = "http://www.cookstr.com"
search_url = base_url + "/searches"
random_url = search_url + "/surprise"
# set this to true to censor this plugin!
censor = True
phrases = [
u"EAT SOME FUCKING \x02{}\x02",
u"YOU WON'T NOT MAKE SOME FUCKING \x02{}\x02",
u"HOW ABOUT SOME FUCKING \x02{}?\x02",
u"WHY DON'T YOU EAT SOME FUCKING \x02{}?\x02",
u"MAKE SOME FUCKING \x02{}\x02",
u"INDUCE FOOD COMA WITH SOME FUCKING \x02{}\x02"
]
clean_key = lambda i: i.split("#")[1]
class ParseError(Exception):
pass
def get_data(url):
""" Uses the omnidator API to parse the metadata from the provided URL """
try:
omni = http.get_json(metadata_url.format(url))
except (http.HTTPError, http.URLError) as e:
raise ParseError(e)
schemas = omni["@"]
for d in schemas:
if d["a"] == "<http://schema.org/Recipe>":
data = {clean_key(key): value for (key, value) in d.iteritems()
if key.startswith("http://schema.org/Recipe")}
return data
raise ParseError("No recipe data found")
@hook.command(autohelp=False)
def recipe(inp):
"""recipe [term] - Gets a recipe for [term], or ets a random recipe if [term] is not provided"""
if inp:
# get the recipe URL by searching
try:
search = http.get_soup(search_url, query=inp.strip())
except (http.HTTPError, http.URLError) as e:
return "Could not get recipe: {}".format(e)
# find the list of results
result_list = search.find('div', {'class': 'found_results'})
if result_list:
results = result_list.find_all('div', {'class': 'recipe_result'})
else:
return "No results"
# pick a random front page result
result = random.choice(results)
# extract the URL from the result
url = base_url + result.find('div', {'class': 'image-wrapper'}).find('a')['href']
else:
# get a random recipe URL
try:
page = http.open(random_url)
except (http.HTTPError, http.URLError) as e:
return "Could not get recipe: {}".format(e)
url = page.geturl()
# use get_data() to get the recipe info from the URL
try:
data = get_data(url)
except ParseError as e:
return "Could not parse recipe: {}".format(e)
name = data["name"].strip()
return u"Try eating \x02{}!\x02 - {}".format(name, web.try_isgd(url))
@hook.command(autohelp=False)
def dinner(inp):
"""dinner - WTF IS FOR DINNER"""
try:
page = http.open(random_url)
except (http.HTTPError, http.URLError) as e:
return "Could not get recipe: {}".format(e)
url = page.geturl()
try:
data = get_data(url)
except ParseError as e:
return "Could not parse recipe: {}".format(e)
name = data["name"].strip().upper()
text = random.choice(phrases).format(name)
if censor:
text = text.replace("FUCK", "F**K")
return u"{} - {}".format(text, web.try_isgd(url))

53
disabled_stuff/status.py Normal file
View file

@ -0,0 +1,53 @@
from util import hook
import re
import time
from subprocess import check_output
def getstatus():
try:
return check_output("sudo /bin/chch-status", shell=True).strip("\n").decode("utf-8")
except:
return "unbekannt"
@hook.command("status", autohelp=False)
def cmd_status(inp, reply=None):
"""status - Return the door status"""
reply("Chaostreff Status: %s" % (getstatus()))
@hook.event("TOPIC")
def topic_update(info, conn=None, chan=None):
"""topic_update -- Update the topic on TOPIC command"""
status = getstatus()
topic = info[-1]
sstr = "Status: %s" % (status)
if sstr in topic:
return
if 'Status: ' in topic:
new_topic = re.sub("Status: [^ ]*", sstr, topic)
else:
new_topic = "%s | %s" % (topic.rstrip(' |'), sstr)
if new_topic != topic:
conn.send("TOPIC %s :%s" % (chan, new_topic))
@hook.event("332")
def e332_update(info, conn=None, chan=None):
"""e332_update -- run after current topic was requested"""
chan = info[1]
topic_update(info, conn=conn, chan=chan)
@hook.singlethread
@hook.event("353")
def e353_update(info, conn=None, chan=None):
"""e353_update -- runs after a channel was joined"""
chan = info[2]
if chan.lower() == "#chaoschemnitz":
conn.send("PRIVMSG Chanserv :op #chaoschemnitz")
while True:
conn.send("TOPIC %s" % (chan))
time.sleep(60)

Some files were not shown because too many files have changed in this diff Show more