Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
467 commits
Select commit Hold shift + click to select a range
183609f
rename tests to test
mutantmonkey May 31, 2012
546b311
tfw: tests and retry on first failure
mutantmonkey May 31, 2012
6aef5ca
add wuvt test
mutantmonkey May 31, 2012
1b7ef76
add imdb tests
mutantmonkey May 31, 2012
b4c5ee8
fix typos in imdb test case
mutantmonkey Jun 1, 2012
59bd004
add hokie stalker tests
mutantmonkey Jun 1, 2012
abc29de
add tests for fcc callsign lookup module
mutantmonkey Jun 1, 2012
5087eb0
clean up slogan.py and add test
mutantmonkey Jun 1, 2012
cf0ce39
add test for short
mutantmonkey Jun 1, 2012
03b7a6d
remove re import from slogan test
mutantmonkey Jun 1, 2012
226b10f
remove my life is desi, add mylife tests
mutantmonkey Jun 1, 2012
34f3f8a
add urban dictionary test
mutantmonkey Jun 1, 2012
f820c6d
split out path adjustments into __init__
mutantmonkey Jun 1, 2012
b272cfd
fix rule34 header and add test
mutantmonkey Jun 1, 2012
da77b27
fix wiktionary and add tests
mutantmonkey Jun 2, 2012
5a3dd40
fix urban dictionary module
mutantmonkey Jun 2, 2012
3f63f79
make testing more clear in readme
mutantmonkey Jun 2, 2012
28cde31
update status and add details to readme
mutantmonkey Jun 2, 2012
9add098
use global GrumbleError for web exceptions
mutantmonkey Jun 2, 2012
30705b8
add what the commit test, simply mylife tests
mutantmonkey Jun 2, 2012
875d6c2
convert tools.py to 4 space indent
mutantmonkey Jun 2, 2012
f54aec3
remove project script (I'm not uusing it)
mutantmonkey Jun 2, 2012
743d927
rename nodetodo and add test
mutantmonkey Jun 2, 2012
f995769
fix translate and add test
mutantmonkey Jun 2, 2012
6fece14
catfacts test and test cleanup
mutantmonkey Jun 2, 2012
ed2a892
add search tests
mutantmonkey Jun 2, 2012
28527c6
use called is True instead of called == 1
mutantmonkey Jun 2, 2012
6979d53
add weather tests
mutantmonkey Jun 2, 2012
0e675fb
calc: remove deprecated, fix wa output, add test
mutantmonkey Jun 2, 2012
888854a
add clock tests
mutantmonkey Jun 2, 2012
f84eb90
validate: fix and add test
mutantmonkey Jun 2, 2012
3dc9582
add nsfw test
mutantmonkey Jun 2, 2012
b87e62d
add randomreddit test
mutantmonkey Jun 2, 2012
fec8173
remove broken etymology module
mutantmonkey Jun 4, 2012
4e8803f
add last.fm tests
mutantmonkey Jun 4, 2012
0d9ad8e
switch to argparse
mutantmonkey Jun 5, 2012
3a82d32
handle GrumbleErrors in a nicer way
mutantmonkey Jun 5, 2012
c702d7b
tfw: handle location errors properly
mutantmonkey Jun 5, 2012
2dbc879
calc: fix .c scientific output
mutantmonkey Jun 6, 2012
931b53a
add .head tests
mutantmonkey Jun 7, 2012
cf53da9
fix wiktionary no results error handling
mutantmonkey Jun 8, 2012
8c5ace9
wuvt: fix artist/track name ordering
mutantmonkey Jun 10, 2012
63c6adb
wuvt: call strip on artist and track name
mutantmonkey Jun 10, 2012
ec32741
refactor mediawiki modules into unified library
mutantmonkey Jun 14, 2012
ce2d548
switch wikipedia to https
mutantmonkey Jun 16, 2012
bf55297
add test cases for mediawiki modules
mutantmonkey Jun 16, 2012
251b01e
calc: fix handling and add tests for empty result
mutantmonkey Jun 20, 2012
2c9a937
.posted
Jun 21, 2012
6ecbe4c
wiki: handle json parsing error
mutantmonkey Jun 24, 2012
9f11190
randomreddit: handle invalid json response
mutantmonkey Jun 24, 2012
78441d5
kill .py
mutantmonkey Jun 29, 2012
52aaa07
Add old link alert to title grabber
Jun 27, 2012
0ba6438
weather: handle bad locations better
mutantmonkey Jun 30, 2012
24a6907
Adding multi-channel support to linx features
Jul 2, 2012
7f55eb7
.lnx to return short remote uploaded links
Aug 30, 2012
7b87bae
Gets title from linx for augmented titling capacity
andreimarcu Sep 25, 2012
7882141
Threadable
Sep 25, 2012
97a3f88
Merge pull request #41 from hansenchris/master
mutantmonkey Sep 25, 2012
0ef5fef
Fixed lastfm module to handle new format.
telnoratti Oct 2, 2012
321e039
Merge pull request #42 from telnoratti/master
mutantmonkey Oct 2, 2012
aaa5026
lastfm: update API key
mutantmonkey Oct 9, 2012
7ea5006
remove randomreddit module
mutantmonkey Oct 9, 2012
4b97b54
ensure lastfm test cases fail when output is bad
mutantmonkey Oct 9, 2012
3d23dc5
Fixed for suspected API change. I think the old key was bound to an o…
telnoratti Oct 9, 2012
4b199e9
Merge pull request #43 from telnoratti/master
mutantmonkey Oct 9, 2012
900ac0c
weather: deal with VRB returned for degrees
mutantmonkey Nov 5, 2012
1002bf0
linx is now optional because of spongebob
Nov 27, 2012
402137d
clean up head.py a bit and readd title brackets
mutantmonkey Nov 27, 2012
f8e2afb
remove broken nodetodo module
mutantmonkey Dec 5, 2012
ac72cb5
fix test_head.py to also mock linx_api_key
mutantmonkey Dec 5, 2012
311b6cb
add linx to default list of disabled modules
mutantmonkey Dec 16, 2012
f59392d
update shebangs
mutantmonkey Dec 16, 2012
56864a4
Add Event Wildcard *
sfan5 Dec 3, 2012
3f2fe64
add KBCB to icao.py
mutantmonkey Dec 21, 2012
62a5ce7
Make '.seen' persistent
rmoore Jan 1, 2013
de05bb7
Merge pull request #46 from rmoore/master
mutantmonkey Jan 1, 2013
7622bd3
fix filename of seen.db files
mutantmonkey Jan 2, 2013
83518a8
add new metar parser and update weather module
mutantmonkey Jan 11, 2013
3e07381
switch tfw module to use new metar parser
mutantmonkey Jan 11, 2013
45da693
fix test cases (wa changed something)
mutantmonkey Jan 11, 2013
5860aca
icao: remove EDDI (closed Berlin-Tempelhof airport)
mutantmonkey Jan 16, 2013
b0712be
fix inHg -> hPa conversion
mutantmonkey Jan 24, 2013
2d337c1
add foodforus module
mutantmonkey Mar 21, 2013
02e45d1
disable foodforus by default
mutantmonkey Mar 21, 2013
29269c7
foodforus: display errors
mutantmonkey Apr 11, 2013
a0597ba
fix Wadsworth's Constant edge case and add test
mutantmonkey May 12, 2013
065fa59
fix immediate ping timeout on quakenet
thekroko Mar 21, 2013
e94ca0d
add unit tests for remind module
mutantmonkey May 21, 2013
bc9d6f3
add .at command (need unit test)
mutantmonkey May 21, 2013
db3b6ba
foodforus: move api_key to end of signature
mutantmonkey May 22, 2013
259c222
linx: force https
mutantmonkey Jun 9, 2013
5cb88f3
switch to requests for HTTP queries
mutantmonkey Jun 9, 2013
caf4a46
metar: handle edge case for pressure parsing
mutantmonkey Jun 13, 2013
5eaea6a
metar: we need to set w.pressure to None
mutantmonkey Jun 13, 2013
899d063
fix .head for errors and add test
mutantmonkey Jul 21, 2013
9460fcd
clean up head module
mutantmonkey Jul 21, 2013
87c57bc
add .travis.yml and requirements.txt
mutantmonkey Jul 21, 2013
dcaa181
add urllib3 to requirements.txt
mutantmonkey Jul 21, 2013
f9374c4
remove version numbers from requirements.txt
mutantmonkey Jul 21, 2013
5d53cc6
remove broken .mlit command
mutantmonkey Jul 21, 2013
aadd97e
fix .hs command to handle new format
mutantmonkey Jul 21, 2013
3783e9a
adjust wiktionary test (will improve later)
mutantmonkey Jul 21, 2013
12ed70f
metar: only add cover if it is not None
mutantmonkey Jul 21, 2013
de8d87c
metar: add ISC license
mutantmonkey Jul 21, 2013
6443442
improvements to weather module
mutantmonkey Aug 25, 2013
f668589
weather: fix error handling (caused breakage)
mutantmonkey Aug 25, 2013
395ca7e
update readme, add travis-ci badge
mutantmonkey Aug 25, 2013
f5fb2fc
update travis-ci badge to point to master
mutantmonkey Aug 25, 2013
23d99dd
improve tests and test coverage
mutantmonkey Aug 25, 2013
cac9258
imdb: switch to omdbapi.com domain
mutantmonkey Aug 25, 2013
b8dde03
hs: handle case where query is <= 2 characters
mutantmonkey Sep 7, 2013
4edf618
tfw: fix "sexy time" for 69°F
mutantmonkey Oct 1, 2013
1472c36
validate: switch site to validate
mutantmonkey Oct 1, 2013
91bbc64
remove oblique and make .wa local
mutantmonkey Oct 1, 2013
b50a12d
improve help
mutantmonkey Oct 1, 2013
6606bf1
add bitcoin module
mutantmonkey Oct 5, 2013
256592b
add help for a bunch of modules
mutantmonkey Oct 5, 2013
5993947
fix lastfm tests (ackthet is gone)
mutantmonkey Oct 5, 2013
d7654c6
last.fm fix: use a user with things in common
mutantmonkey Oct 5, 2013
2e99547
bitcoin: uppercase currencies for api
mutantmonkey Oct 26, 2013
3988a73
tfw: deal with negative temperatures in test
mutantmonkey Oct 26, 2013
e195830
translate: json cleanup improvement
mutantmonkey Nov 2, 2013
6686ce3
fix weather tests to handle new osm output
mutantmonkey Nov 2, 2013
d692a52
move calculator functionality to ddg
mutantmonkey Nov 5, 2013
c3815c9
improvements to calc module
mutantmonkey Nov 17, 2013
8061396
bitcoin: support decimal input
mutantmonkey Nov 18, 2013
58da599
tfw: add "it's fucking hot"
mutantmonkey Nov 27, 2013
d6e28ac
fix translate test to match new output
mutantmonkey Nov 29, 2013
9219308
Added minor documentation
mattr555 Nov 29, 2013
b62dc01
added .botslap
mattr555 Nov 29, 2013
cbcb25a
Updated .seen, added time since to response
mattr555 Nov 29, 2013
4fa63e7
Updated .time to the newer version of phenny
mattr555 Nov 29, 2013
26f37e8
update test case for new .time
mutantmonkey Nov 29, 2013
8fa37b3
fix gettitle errors
mutantmonkey Nov 29, 2013
5f451af
Revert "added .botslap"
mutantmonkey Dec 12, 2013
f8c25e5
fix foodforus
mutantmonkey Jan 20, 2014
2da9ed0
Removed .posted, .lines, augmented title retrieval.
andreimarcu Apr 1, 2014
a671133
Added .posted (local version)
andreimarcu Apr 6, 2014
1b8e52b
Load .posted only if it is a registered module.
andreimarcu Apr 7, 2014
b20e921
Merge pull request #51 from andreimarcu/master
mutantmonkey Apr 7, 2014
5d50d54
update snarfuri to exclude command-line lines
mutantmonkey Apr 9, 2014
b9f0da7
Added default support for meters.
telnoratti Apr 25, 2014
9248b67
Fixed the tests.
telnoratti Apr 25, 2014
b73a048
Changed capitalization of eV.
Apr 26, 2014
b74d89e
Merge pull request #52 from telnoratti/master
mutantmonkey Apr 26, 2014
eac8d18
Fixed the lastfm tests.
Apr 26, 2014
b0edaf9
Merge pull request #53 from telnoratti/master
mutantmonkey Apr 26, 2014
9b05dcc
tfw: correct formula to calculate electron volts
mutantmonkey May 15, 2014
0fe637c
use new python 3.4 TLS features if possible
mutantmonkey Jun 2, 2014
5ded3dc
disable nonblocking sockets again
mutantmonkey Jun 2, 2014
eb21193
read ca_certs from config
mutantmonkey Jun 2, 2014
4cdda19
remove broken modules
mutantmonkey Jun 2, 2014
8654e70
require certificates for TLS connections
mutantmonkey Jun 2, 2014
2e7cf02
Update wuvt.py
matthazinski Nov 8, 2014
cbd75bb
Merge pull request #54 from matthazinski/patch-1
mutantmonkey Nov 8, 2014
202681e
Update wuvt.py
matthazinski Nov 8, 2014
d1ab481
Merge pull request #55 from matthazinski/patch-2
mutantmonkey Nov 8, 2014
0490ede
mylife: remove .mlih
mutantmonkey Nov 8, 2014
83b286e
Update foodforus.py
matthazinski Dec 29, 2014
d963ac2
update wuvt module for new site
mutantmonkey Mar 6, 2015
df08d3e
wuvt: remove DJ prefix
mutantmonkey Mar 21, 2015
bfccb28
wuvt: add listener count support
mutantmonkey Apr 6, 2015
bafc772
Update API key
Apr 22, 2015
5799410
Merge pull request #58 from wad209/master
mutantmonkey Apr 22, 2015
a3b0fbc
remove channel reference in readme
mutantmonkey Jul 1, 2015
179ed31
tfw: update remarks
mutantmonkey Jan 12, 2016
c859ad0
weather: use https for the nominatim
mutantmonkey Jan 12, 2016
62893cb
wuvt: update output format
mutantmonkey Jan 12, 2016
cee9e09
update part rule
mutantmonkey Jan 12, 2016
5e381c6
Travis-CI: use "container-based infrastructure"
mutantmonkey Mar 6, 2016
7875789
Travis-CI: enable more python versions
mutantmonkey Mar 6, 2016
b0258f6
remove broken mylife commands
mutantmonkey Mar 6, 2016
347b979
remove broken bitcoin module
mutantmonkey Mar 6, 2016
64d7088
validate: use https
mutantmonkey Mar 6, 2016
984dba9
lastfm: remove tasteometer
mutantmonkey Mar 6, 2016
59e7cb3
translate: switch to https
mutantmonkey Mar 6, 2016
01fea46
search: use https for bing, duckduckgo, and google
mutantmonkey Mar 6, 2016
2f34c76
calc: remove broken wa command
mutantmonkey Mar 6, 2016
23e9448
fix tests for head and weather
mutantmonkey Mar 6, 2016
1934dcc
Travis-CI: drop --use-mirrors from pip install
mutantmonkey Mar 6, 2016
24bf711
search: fix bing regex
mutantmonkey Mar 6, 2016
35e7b56
fix some more tests
mutantmonkey Mar 6, 2016
fcf22d7
remove broken validate module
mutantmonkey Mar 6, 2016
2dc0b0b
remove broken translate module
mutantmonkey Mar 6, 2016
a981cf3
modify phenny.say() to split long messages
EgorMatirov Dec 5, 2014
919b65c
fix imdb, search, and various tests
paulwalko Feb 11, 2017
e5cf2d8
fix imdb, search, and various tests
paulwalko Feb 11, 2017
55de025
fix imdb, search, and various tests
paulwalko Feb 11, 2017
c13a95d
fix .g search regex
paulwalko Feb 11, 2017
7ad0d5a
fix tfw tests
paulwalko Feb 11, 2017
58d41a0
fix weather url
paulwalko Feb 11, 2017
b2add77
properly skip vtwiki tests and, enable calc tests (2^64) was disabled
paulwalko Feb 11, 2017
71c5f90
remove old comments
paulwalko Feb 11, 2017
f195b7c
Merge pull request #61 from wei2912/upstream-irc
mutantmonkey Feb 11, 2017
c8f4da2
remove Midlothian, Virginia weather test; Improve duck_api readibility
paulwalko Feb 12, 2017
77133f7
remove tor2web gateway
paulwalko Feb 12, 2017
e4d28c0
Merge pull request #70 from vtluug/master
mutantmonkey Feb 12, 2017
f02bcae
Use 'postalcode' parameter when a zipcode is used to get more accurat…
paulwalko Feb 17, 2017
149f02a
Change etymology/definition syntax for parsing json
paulwalko Feb 17, 2017
1249804
Change etymology/definition syntax for parsing json
paulwalko Feb 17, 2017
4b45f8d
Merge branch 'master' of git://github.com/mutantmonkey/phenny
paulwalko Feb 17, 2017
a10f513
Add &quot; to unescape function in wiki.py
paulwalko Feb 21, 2017
538fec6
Clean up core and add support for TLS client certs
mutantmonkey Apr 10, 2017
20cc193
Restore VTLUUG wiki tests since it's back up
mutantmonkey Apr 10, 2017
999297b
Python 3.4+ is now required
mutantmonkey Apr 10, 2017
42325d8
update travis python versions
mutantmonkey Apr 10, 2017
7dc5ece
Merge pull request #1 from mutantmonkey/master
paulwalko May 27, 2017
7c67f09
scrape calc results from google since ddg is broken
May 28, 2017
a000881
mylife html changed again
May 28, 2017
5583997
create generic google function to share with calculator
May 28, 2017
8598fdc
forgot to change ddg url back
paulwalko May 28, 2017
f444326
remove old code
paulwalko May 29, 2017
d8eefde
remove unicode
paulwalko May 29, 2017
9e8899b
remove old code & use format
paulwalko May 29, 2017
74a70e1
Merge pull request #71 from vtluug/master
mutantmonkey Jun 3, 2017
65afe65
add some more tfw comments, especially for inclement weather
echarlie Jun 3, 2017
5ace33e
Add regex to skip ads on ddg
paulwalko Jun 7, 2017
e4b4b50
change Midotholian to Chesterfield County b/c nominatim is broken
paulwalko Jun 9, 2017
89e567a
Merge pull request #73 from vtluug/fix_ddg_ads
mutantmonkey Jun 9, 2017
e0b8f7d
Merge pull request #72 from vtluug/fix_weather
mutantmonkey Jun 9, 2017
f49a1a6
Fix help text
mutantmonkey Jun 9, 2017
1cd247e
.c bugfix
paulwalko Jul 7, 2017
1eb1c36
Merge pull request #74 from vtluug/calc_bugfix
mutantmonkey Jul 7, 2017
4386572
Merge branch 'master' into tfw_improvements
echarlie Jul 29, 2017
4acda54
clean up some of the formatting, revise/add a few flavours
echarlie Jul 29, 2017
30167a5
Merge pull request #5 from vtluug/tfw_improvements
echarlie Oct 20, 2017
f6d9e17
fix tests, also correct erroneous help for tfwev
echarlie Nov 4, 2017
d9cce4f
Merge pull request #76 from vtluug/master
mutantmonkey Nov 9, 2017
46d3785
use Fisher Island instead of the county
paulwalko Dec 27, 2017
ef8d253
undo split messages
paulwalko Dec 27, 2017
55ae9eb
Merge pull request #79 from vtluug/undo_long_messages
mutantmonkey Dec 30, 2017
fd9f7c7
wuvt: don't blow up if listeners is None
mutantmonkey Jan 23, 2018
f523feb
Merge pull request #78 from vtluug/fix_weather
mutantmonkey Mar 24, 2018
f39902f
Drop Python 3.4 support for now
mutantmonkey Mar 24, 2018
2153d27
Simplify assigning default config values
Androbin Mar 12, 2018
e91f3bd
Refactor Wikipedia modules
Androbin Mar 16, 2018
a6c525e
Update Wikipedia tests
Androbin Mar 22, 2018
8e98412
Merge pull request #82 from Androbin/mutant
mutantmonkey Apr 28, 2018
07b257c
[weather.py] Drop display_name and test coordinates
Androbin Apr 2, 2018
5b7a598
Merge branch 'Androbin-weather'
mutantmonkey Apr 28, 2018
bc5be32
Provide dedicated methods for protocol messages
Androbin Mar 14, 2018
44084c8
Fix awik test
Androbin Jul 31, 2018
462e7ba
Fix urbandict data['result_type']
Androbin Jul 31, 2018
00db666
Update test_weather.py
Androbin Jul 31, 2018
9b7d64d
Merge pull request #85 from Androbin/proto
mutantmonkey Aug 28, 2018
e716729
Replace deprecated imp module with importlib
mutantmonkey Oct 8, 2018
c42438b
Add Dockerfile
mutantmonkey Oct 9, 2018
378edca
.travis.yml: add Python 3.7, try forcing LANG
mutantmonkey Oct 13, 2018
b34e07b
Use newton api instead of google calc regex
paulwalko Jun 21, 2019
67037cf
Merge pull request #90 from paulwalko/calc
mutantmonkey Jun 21, 2019
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
1 change: 1 addition & 0 deletions .coverage

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.pyc
.DS_Store
*~
*.swp
__pycache__
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python
sudo: false
cache: pip
python:
- 3.5
- 3.6
- 3.7
install:
- pip install -r requirements.txt
script:
- LANG=en_US.UTF-8 nosetests
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3

WORKDIR /usr/src/app

COPY requirements.txt /usr/src/app/
RUN pip install --no-cache-dir -r requirements.txt

COPY . /usr/src/app/

RUN groupadd -r -g 200 bot \
&& useradd -mr -g bot -u 200 bot
USER bot

VOLUME ["/home/bot/.phenny"]

CMD ["/usr/src/app/phenny"]
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# phenny
[![Build Status](https://travis-ci.org/mutantmonkey/phenny.png?branch=master)](https://travis-ci.org/mutantmonkey/phenny)

This is phenny, a Python IRC bot. Originally written by Sean B. Palmer, it has
been ported to Python3.

This version comes with many new modules, IPv6 support, TLS support, and unit
tests.

Compatibility with existing phenny modules has been mostly retained, but they
will need to be updated to run on Python3 if they do not already. All of the
core modules have been ported, removed, or replaced.

## Requirements
* Python 3.4+
* [python-requests](http://docs.python-requests.org/en/latest/)

## Installation
1. Run `./phenny` - this creates a default config file
2. Edit `~/.phenny/default.py`
3. Run `./phenny` - this now runs phenny with your settings

Enjoy!

## Testing
You will need the Python3 versions of `python-nose` and `python-mock`. To run
the tests, simply run `nosetests3`.

## Authors
* Sean B. Palmer, http://inamidst.com/sbp/
* mutantmonkey, http://mutantmonkey.in
10 changes: 0 additions & 10 deletions README.txt

This file was deleted.

133 changes: 79 additions & 54 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
__init__.py - Phenny Init Module
Copyright 2008, Sean B. Palmer, inamidst.com
Expand All @@ -7,56 +7,81 @@
http://inamidst.com/phenny/
"""

import sys, os, time, threading, signal
import bot

class Watcher(object):
# Cf. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496735
def __init__(self):
self.child = os.fork()
if self.child != 0:
self.watch()

def watch(self):
try: os.wait()
except KeyboardInterrupt:
self.kill()
sys.exit()

def kill(self):
try: os.kill(self.child, signal.SIGKILL)
except OSError: pass

def run_phenny(config):
if hasattr(config, 'delay'):
delay = config.delay
else: delay = 20

def connect(config):
p = bot.Phenny(config)
p.run(config.host, config.port)

try: Watcher()
except Exception, e:
print >> sys.stderr, 'Warning:', e, '(in __init__.py)'

while True:
try: connect(config)
except KeyboardInterrupt:
sys.exit()

if not isinstance(delay, int):
break

warning = 'Warning: Disconnected. Reconnecting in %s seconds...' % delay
print >> sys.stderr, warning
time.sleep(delay)

def run(config):
t = threading.Thread(target=run_phenny, args=(config,))
if hasattr(t, 'run'):
t.run()
else: t.start()

if __name__ == '__main__':
print __doc__
import os
import signal
import sys
import threading
import time


class Watcher(object):
# Cf. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496735
def __init__(self):
self.child = os.fork()
if self.child != 0:
signal.signal(signal.SIGTERM, self.sig_term)
self.watch()

def watch(self):
try:
os.wait()
except KeyboardInterrupt:
self.kill()
sys.exit()

def kill(self):
try:
os.kill(self.child, signal.SIGKILL)
except OSError:
pass

def sig_term(self, signum, frame):
self.kill()
sys.exit()


def run_phenny(config):
if hasattr(config, 'delay'):
delay = config.delay
else:
delay = 20

def connect(config):
import bot
p = bot.Phenny(config)

ssl_context = p.get_ssl_context(config.ca_certs)
if config.ssl_cert and config.ssl_key:
ssl_context.load_cert_chain(config.ssl_cert, config.ssl_key)
p.run(config.host, config.port, config.ssl, config.ipv6, None,
ssl_context)

try:
Watcher()
except Exception as e:
print('Warning:', e, '(in __init__.py)', file=sys.stderr)

while True:
try:
connect(config)
except KeyboardInterrupt:
sys.exit()

if not isinstance(delay, int):
break

msg = "Warning: Disconnected. Reconnecting in {0} seconds..."
print(msg.format(delay), file=sys.stderr)
time.sleep(delay)


def run(config):
t = threading.Thread(target=run_phenny, args=(config,))
if hasattr(t, 'run'):
t.run()
else:
t.start()


if __name__ == '__main__':
print(__doc__)
Loading