Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions defaults/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ module.exports = {
timezone: "UTC+00:00"
},

//
// Maximum number of history lines per channel
//
// Defines the maximum number of history lines that will be kept in
// memory per channel/query, in order to reduce the memory usage of
// the server. 0 means unlimited.
//
// @type integer
// @default 0
maxHistory: 0,

//
// Default values for the 'Connect' form.
//
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/irc-events/message.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
var _ = require("lodash");
var Chan = require("../../models/chan");
var Msg = require("../../models/msg");
var Helper = require("../../helper");
var config = {};

module.exports = function(irc, network) {
var client = this;
config = Helper.getConfig();

irc.on("message", function(data) {
if (data.message.indexOf("\u0001") === 0 && data.message.substring(0, 7) !== "\u0001ACTION") {
// Hide ctcp messages.
Expand Down Expand Up @@ -56,7 +60,13 @@ module.exports = function(irc, network) {
text: text,
self: self
});

chan.messages.push(msg);

if (config.maxHistory > 0 && chan.messages.length > config.maxHistory) {
chan.messages.splice(0, chan.messages.length-config.maxHistory);
}

client.emit("msg", {
chan: chan.id,
msg: msg
Expand Down