Comments (3)
By default, the IRC library does attempt to decode all incoming streams as UTF-8, but I acknowledge that there are cases where decoding is undesirable or a custom decoding option is desirable. To support these cases, since irc 3.4.2, the ServerConnection class may be customized. The 'buffer_class' attribute on the ServerConnection determines what class is used for buffering lines from the input stream. By default it is DecodingLineBuffer, but may be re-assigned with another class, such as irc.client.LineBuffer, which does not decode the lines and passes them through as byte strings. The 'buffer_class' attribute may be assigned for all instances of ServerConnection by overriding the class attribute::
irc.client.ServerConnection.buffer_class = irc.client.LineBuffer
or it may be overridden on a per-instance basis (as long as it's overridden before the connection is established)::
server = irc.client.IRC().server()
server.buffer_class = irc.client.LineBuffer
server.connect()
I've added a section to the README that documents these options.
Does this interface provide the option you seek? If not, please re-open.
Original comment by: Jason R. Coombs
from irc.
I've updated the README in https://bitbucket.org/jaraco/irc/changeset/807ab45d31fe to describe the option available to disable/customize encoding.
Original comment by: Jason R. Coombs
from irc.
Thank you for the reply. It helped me a lot, but I've come up with another problem, mainly because I'm using Python 3.
The library has somewhat mixed uses between bytes
and str
, and when you convert bytes
to str
implicitly it would result "b'this'"
.
We should explicitly choose what to use between two kinds of strings, and I would like to recommend bytes
. For example, the channel names are allowed to contain almost any sequences of bytes as specified by RFC 1459, so bytes
should be suitable. But when you do that, every line would become problematic:
- In
irc.client.is_channel()
:string[0] in "#&+!"
- In
irc.client.ServerConnection.join()
:"JOIN %s%s" % (channel, (key and (" " + key)))
NickMask(prefix)
when a privmsg event has occured
So I'm trying to convert all the internal strings to bytes
on my fork, in a similar fashion I've done to irclib
: https://github.com/puzzlet/python-irclib
Original comment by: puzzlet
from irc.
Related Issues (20)
- Add example on how to send a message to a channel HOT 1
- How can i print irc messages in my console?
- Disconnect issue HOT 1
- Implement default handler if nothing matches HOT 1
- [AIO] No client side ping-pong
- [AIO] Excess flood prevention HOT 3
- [AIO] Registering a connection needs to be split out of connect() HOT 1
- [AIO] Connection real_nickname must not be set before registration HOT 1
- [AIO] Implement SASL PLAIN with expect() flow
- High CPU usage in irc.server. HOT 1
- Add support for ignoring ssl validation in the examples HOT 2
- Add support for SASL HOT 4
- In tests DeprecationWarning no event loop
- ValueError when trying to download using DCC HOT 2
- Basic irc bot HOT 1
- DCC Transfers getting stuck HOT 1
- Test regressions: irc/dict.py::irc.dict.IRCDict, irc/strings.py::irc.strings.IRCFoldedCase
- Example for creating multiple connections to a server? HOT 1
- After joining a channel, how do I get a list of usernames? HOT 1
- 'AioReactor' object has no attribute 'scheduler' HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from irc.