Don't *require* that IRC() already know about your server, just add
some nicknames for ease of use. Now it's easy to point IRC() at any
qwebirc client you like.
-ipython-irc: An IRC iframe using webchat.freenode.net_
+ipython-irc: An IRC iframe that connects to qwebirc_ instances.
-Connect to freenode_ from IPython!
+`Many IRC networks`_ run public qwebirc instances. For example:
+
+* Freenode_
+* EFNet_
+
+Connect to them from IPython_!
Installation
============
Installation
============
-.. _webchat.freenode.net: http://webchat.freenode.net/
-.. _freenode: http://freenode.net/
+.. _qwebirc: http://qwebirc.org/
+.. _Many IRC networks: http://qwebirc.org/about
+.. _Freenode: http://webchat.freenode.net/
+.. _EFNet: http://chat.efnet.org:9090/
.. _layman: http://layman.sourceforge.net/
.. _wtk overlay: http://blog.tremily.us/posts/Gentoo_overlay/
.. _Debian: http://www.debian.org/
.. _layman: http://layman.sourceforge.net/
.. _wtk overlay: http://blog.tremily.us/posts/Gentoo_overlay/
.. _Debian: http://www.debian.org/
Use with::
IRC(nick='you', channels=('#ipython', ...)).show()
Use with::
IRC(nick='you', channels=('#ipython', ...)).show()
+
+ You can give the server explicitly::
+
+ IRC(server='http://webchat.freenode.net/', ...)
+
+ or use some common nicknames::
+
+ IRC(server='freenode', ...)
+ IRC(server='efnet', ...)
- def __init__(self, server='chat.freenode.net', nick=None,
+ base_urls = { # convenient nicknames for common networks
+ 'freenode': 'http://webchat.freenode.net/',
+ 'efnet': 'http://chat.efnet.org:9090/',
+ }
+
+ def __init__(self, server='http://webchat.freenode.net/', nick=None,
channels=('#ipython','#rogue'), width=647, height=400):
self.server = server
self.nick = nick
self.channels = channels
self.width = width
self.height = height
channels=('#ipython','#rogue'), width=647, height=400):
self.server = server
self.nick = nick
self.channels = channels
self.width = width
self.height = height
- if self.server not in [
- 'chat.freenode.net',
- ]:
- raise NotImplementedError(self.server)
+ def _get_server(self):
+ server = self.server
+ if not server.startswith('http://'):
+ base = self.base_urls.get(server, None)
+ if not base:
+ raise NotImplementedError(
+ '{!r} not supported. We *do* support {}'.format(
+ self.server, self.base_urls))
+ return server
+
+ def _get_data(self):
data = {}
for attr in ['nick', 'channels']:
value = getattr(self, attr)
data = {}
for attr in ['nick', 'channels']:
value = getattr(self, attr)
data[attr] = value
else:
data['prompt'] = 1
data[attr] = value
else:
data['prompt'] = 1
- url = '{}?{}'.format(
- 'http://webchat.freenode.net',
- _urllib_parse.urlencode(data)
- )
+ return data
+
+ def _get_url(self):
+ return '{}?{}'.format(
+ self._get_server(),
+ _urllib_parse.urlencode(self._get_data()))
+
+ def _html(self):
+ url = self._get_url()
return '<iframe src="{}" width="{}" height="{}"></iframe>'.format(
url, self.width, self.height)
return '<iframe src="{}" width="{}" height="{}"></iframe>'.format(
url, self.width, self.height)
# You should have received a copy of the GNU General Public License along with
# ipython-irc. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License along with
# ipython-irc. If not, see <http://www.gnu.org/licenses/>.
-"An IRC iframe using webchat.freenode.net"
+"An IRC iframe that connects to qwebirc instances"
from distutils.core import setup
from distutils.core import setup