aboutsummaryrefslogtreecommitdiffstats
path: root/src/Plugin/Base.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-20 13:51:31 +0200
committerTeddy Wing2017-08-20 15:15:14 +0200
commit44d8c54867a52381ec741a3b4365a91447059502 (patch)
tree058372ba413be0e993c18803686d3ff305c486c4 /src/Plugin/Base.hs
parentc543eebfcbd92bb261003dbfd658487b59362a5b (diff)
downloadsorbot-44d8c54867a52381ec741a3b4365a91447059502.tar.bz2
IRC: Chop messages longer than 400 characters
The IRC protocol doesn't permit messages longer than 512 bytes (https://news.ycombinator.com/item?id=7991049). This includes server, channel, hostname, etc. information that's also included in the message. In order to be able to send longer messages, chop them at 400 characters (https://wholok.com/irc/), which seems like a "reasonable" hard-coded value. We already split our messages at newlines, so we need to effectuate a double split here. First we split at 400 characters because we might have a line that runs longer than that before encountering a newline. To do this, we use the `chunksOf` function (https://wiki.haskell.org/Data.List.Split). Then, when splitting on newlines, we take the list produced by splitting at 400 characters, and must split the elements inside that list. This creates a two-dimensional array. In order to flatten the array, we use the `concat` function (https://stackoverflow.com/questions/5994051/is-there-a-function-to-flatten-a-nested-list-of-elements).
Diffstat (limited to 'src/Plugin/Base.hs')
0 files changed, 0 insertions, 0 deletions