Skip to content

Commit db5cbc4

Browse files
committed
Merge branch 'master' into remindme-plugin
2 parents b6a1560 + 6e7d6e1 commit db5cbc4

91 files changed

Lines changed: 2379 additions & 848 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.*.swp
22
*.pyc
33
*.orig
4+
.tox/
45
persist
56
config
67
config.json
@@ -9,3 +10,10 @@ pep8.py
910
.pydevproject
1011
*.db
1112
web
13+
bin/
14+
lib/
15+
include/
16+
local/
17+
pip-selfcheck.json
18+
pyvenv/
19+

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sudo: false
2+
dist: xenial
3+
language: python
4+
python:
5+
- "2.7"
6+
- "3.7"
7+
install: pip install tox-travis
8+
script: tox
9+
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
= Skybot =
1+
# Skybot
22

3-
==Goals==
3+
## Goals
44
* simplicity
5-
** little boilerplate
6-
** minimal magic
5+
* little boilerplate
6+
* minimal magic
77
* power
8-
** multithreading
9-
** automatic reloading
10-
** extensibility
8+
* multithreading
9+
* automatic reloading
10+
* extensibility
1111

12-
==Features==
12+
# Features
1313
* Multithreaded dispatch and the ability to connect to multiple networks at a time.
1414
* Easy plugin development with automatic reloading and a simple hooking API.
1515

16-
==Requirements==
16+
# Requirements
1717
To install dependencies, run:
1818

1919
pip install -r requirements.txt
2020

21-
Skybot runs on Python 2.7.
21+
Skybot runs on Python 2.7 and Python 3.7.
2222

23-
==License==
23+
## License
2424
Skybot is public domain. If you find a way to make money using it, I'll be very impressed.
2525

2626
See LICENSE for precise terms.

bot.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

3+
from __future__ import print_function
34
import os
4-
import Queue
5+
import queue
56
import sys
67
import traceback
78
import time
89

910

10-
class Bot(object):
11+
class Bot:
1112
def __init__(self):
1213
self.conns = {}
1314
self.persist_dir = os.path.abspath('persist')
@@ -21,38 +22,38 @@ def main():
2122
sys.path += ['lib']
2223
os.chdir(os.path.dirname(__file__) or '.') # do stuff relative to the install directory
2324

24-
print 'Loading plugins'
25+
print('Loading plugins')
2526

2627
# bootstrap the reloader
27-
eval(compile(open(os.path.join('core', 'reload.py'), 'U').read(),
28+
eval(compile(open(os.path.join('core', 'reload.py'), 'r').read(),
2829
os.path.join('core', 'reload.py'), 'exec'),
2930
globals())
3031
reload(init=True)
3132

32-
print 'Connecting to IRC'
33+
print('Connecting to IRC')
3334

3435
try:
3536
config()
3637
if not hasattr(bot, 'config'):
3738
exit()
38-
except Exception, e:
39-
print 'ERROR: malformed config file:', e
39+
except Exception as e:
40+
print('ERROR: malformed config file:', e)
4041
traceback.print_exc()
4142
sys.exit()
4243

43-
print 'Running main loop'
44+
print('Running main loop')
4445

4546
while True:
4647
reload() # these functions only do things
4748
config() # if changes have occured
4849

49-
for conn in bot.conns.itervalues():
50+
for conn in bot.conns.values():
5051
try:
5152
out = conn.out.get_nowait()
5253
main(conn, out)
53-
except Queue.Empty:
54+
except queue.Empty:
5455
pass
55-
while all(conn.out.empty() for conn in bot.conns.itervalues()):
56+
while all(conn.out.empty() for conn in iter(bot.conns.values())):
5657
time.sleep(.1)
5758

5859
if __name__ == '__main__':

core/config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import inspect
23
import json
34
import os
@@ -51,16 +52,19 @@ def config():
5152
try:
5253
bot.config = json.load(open(find_config()))
5354
bot._config_mtime = config_mtime
54-
for name, conf in bot.config['connections'].iteritems():
55+
56+
for name, conf in bot.config['connections'].items():
57+
conf.setdefault('censored_strings', bot.config.get('censored_strings', []))
58+
5559
if name in bot.conns:
5660
bot.conns[name].set_conf(conf)
5761
else:
5862
if conf.get('ssl'):
5963
bot.conns[name] = SSLIRC(conf)
6064
else:
6165
bot.conns[name] = IRC(conf)
62-
except ValueError, e:
63-
print 'ERROR: malformed config!', e
66+
except ValueError as e:
67+
print('ERROR: malformed config!', e)
6468

6569

6670
bot._config_mtime = 0

core/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def get_db_connection(conn, name=''):
66
"returns an sqlite3 connection to a persistent database"
77

88
if not name:
9-
name = '%s.%s.db' % (conn.nick, conn.server)
9+
name = '%s.%s.db' % (conn.nick, conn.server_host)
1010

1111
filename = os.path.join(bot.persist_dir, name)
1212
return sqlite3.connect(filename, timeout=10)

0 commit comments

Comments
 (0)