Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
irc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
irc
Commits
5d53641a
Commit
5d53641a
authored
10 years ago
by
Diego MartÃnez
Committed by
Diego Martinez
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Split messages going out to avoid cutouts.
parent
38832b3c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
init.lua
+26
-1
26 additions, 1 deletion
init.lua
with
26 additions
and
1 deletion
init.lua
+
26
−
1
View file @
5d53641a
...
...
@@ -122,6 +122,18 @@ function irc:disconnect(message)
end
-- Split messages into smaller messages of this size to avoid cutting
-- off large messages at the end.
-- Note: RFC 2812 specifies a maximum of 512 characters per "line"
-- (that includes the command, parameter(s), and the "\r\n" at the
-- end). We just use a smaller number to avoid having to compute the
-- actual max length ourselves, and because it makes it a nice round
-- number :)
local
MESSAGE_CHUNK_SIZE
=
400
-- Maximum message size processed.
local
MESSAGE_MAX_SIZE
=
MESSAGE_CHUNK_SIZE
*
4
function
irc
:
say
(
to
,
message
)
if
not
message
then
message
=
to
...
...
@@ -129,7 +141,20 @@ function irc:say(to, message)
end
to
=
to
or
self
.
config
.
channel
self
:
queue
(
irc
.
msgs
.
privmsg
(
to
,
message
))
message
=
message
:
sub
(
1
,
MESSAGE_MAX_SIZE
)
-- Split the message into MESSAGE_CHUNK_SIZE chunks and queue each
-- chunk as a separate message. The message is split into at most
-- MAX_CHUNKS chunks. The rest of the message is dropped to prevent
-- flooding and/or locking up the server.
local
msglen
=
#
message
for
pos
=
1
,
msglen
,
MESSAGE_CHUNK_SIZE
do
-- If we have more text to show, indicate so by appending an
-- ellipsis to this line.
local
endl
=
(
pos
<=
(
msglen
-
MESSAGE_CHUNK_SIZE
))
and
"
\2
[…more…]\2"
or
""
self
:
queue
(
irc
.
msgs
.
privmsg
(
to
,
message
:
sub
(
pos
,
pos
+
MESSAGE_CHUNK_SIZE
-
1
)
..
endl
))
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment