question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Store all bot messages

See original GitHub issue

How would I store all the context.event.message.text for every request from all users without programming it into each handler?

My storing these it will be a great tool to see which commands are popular and most mis-typed. Also a great way to see indirectly the new commands people are looking for.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
chentsulincommented, Jan 19, 2018

Bottender has three different approaches to get this done, but we haven’t figured out which one is better yet.

  1. Use server middleware. You can save JSON-parsed request body here, for example:

Express:

const { createServer } = require('bottender/express');

const bot = require('./bot');

const middleware = (req, res, next) => {
  // do something here to save req.body
  next();
};

const server = createServer(bot, {
  webhookMiddleware: middleware,
});

Koa:

const { createServer } = require('bottender/koa');

const bot = require('./bot');

const middleware = (ctx, next) => {
  // do something here to save ctx.request.body
  return next();
};

const server = createServer(bot, {
  webhookMiddleware: middleware,
});
  1. Put it on the top of your root handler
bot.onEvent(async context => {
  if (context.event.isText) {
    // do something here to save context.event.text
  }
  
  // other....
});
  1. Use plugin (this a hidden feature we are currently working on)
bot.use(async context => {
  if (context.event.isText) {
    // do something here to save context.event.text
  }
});

bot.onEvent(...);
0reactions
chentsulincommented, Sep 27, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

storing messages with a discord bot - Stack Overflow
If you want to store all the information of the message, you can do: file.write(f'{message}\n'). or file.write(str(message) + '\n').
Read more >
Can Discord bots store messages from DM's if deleted? - Reddit
There's nothing stopping a bot from saving all information it can get about every message it sees. Pretty sure most bots don't do...
Read more >
How to STORE Information with a Discord Bot! - YouTube
Want to be able to STORE information using a Discord Bot ? Want to be able to store data and information in a...
Read more >
Telegram bot message stores in categorized mode · Issue #269
Project description If possible, develop a Telegram bot, that archives any message that forward to it in categorize and get them back via...
Read more >
How to Gather Message Data Using a Discord Bot From ...
To do so, we use the on_message() asynchronous function from the discord.py library, which runs every time a new message is sent. Then,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found