Skip to content

Commit 33403d0

Browse files
committed
Factoid: Truncate messages to 512 characters
1 parent a92e622 commit 33403d0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ where
230230

231231
#[derive(Clone, Debug)]
232232
struct ThreadedPlugins<C: FrippyClient> {
233-
plugins: HashMap<String, Arc<Plugin<Client = C>>>,
233+
plugins: HashMap<String, Arc<dyn Plugin<Client = C>>>,
234234
}
235235

236236
impl<C: FrippyClient + 'static> ThreadedPlugins<C> {

src/plugins/factoid/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ impl<T: Database, C: Client> Factoid<T, C> {
139139
.get_factoid(name, idx)
140140
.context(ErrorKind::NotFound)?;
141141

142-
let message = factoid.content.replace("\n", "|").replace("\r", "");
142+
let mut message = factoid.content.replace("\n", "|").replace("\r", "");
143+
message.truncate(512);
143144

144145
Ok(format!("{}: {}", factoid.name, message))
145146
}
@@ -179,7 +180,7 @@ impl<T: Database, C: Client> Factoid<T, C> {
179180
let factoid = self.factoids.read().get_factoid(&name, count - 1)?;
180181

181182
let content = factoid.content;
182-
let value = if content.starts_with('>') {
183+
let mut message = if content.starts_with('>') {
183184
let content = String::from(&content[1..]);
184185

185186
if content.starts_with('>') {
@@ -197,7 +198,8 @@ impl<T: Database, C: Client> Factoid<T, C> {
197198
content
198199
};
199200

200-
Ok(value.replace("\n", "|").replace("\r", ""))
201+
message.truncate(512);
202+
Ok(message.replace("\n", "|").replace("\r", ""))
201203
}
202204
}
203205

0 commit comments

Comments
 (0)