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.

Can I cache the peer information to redis and use it to send message?

See original GitHub issue

Dear all,

I have a task to send multiple messages to just ONE person by him username. I got this error FloodWaitError: A wait of 24597 seconds is required (caused by contacts.ResolveUsername)

So, my idea is use Redis to cache the peer information and use it to sending message to the same people the next time.

I am following this article to rebuild the peer object by the cached information https://gram.js.org/beta/classes/Api.PeerUser.html

 var u = {
    peer: { 
      userId: BigInt(xxx), 
      className: 'PeerUser',
      CONSTRUCTOR_ID: 1498486562,
      SUBCLASS_OF_ID: 47470215,
      classType: 'constructor'
    }
  }

var p = new Api.PeerUser(u.peer);

Then send message by the API

let res = await client.invoke(new Api.messages.SendMessage({
        peer: p,
        message: message      
}));
console.log(res)

I got this error:

Error: Could not find the input entity for {"userId":"xxx","className":"PeerUser","CONSTRUCTOR_ID":1498486562,"SUBCLASS_OF_ID":47470215,"classType":"constructor"}.

Can you tell me why? Thanks for your time!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
painorcommented, Aug 16, 2022

it’s not a bug. this is just how javascript works. image

you can’t use normal numbers to represent big integers

0reactions
laocoicommented, Aug 16, 2022

I try Helpers.returnBigInt('-3563441647559576810') and it work. I think there is a bug at here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client-side caching in Redis
When client-side caching is used, the application will store the reply of popular ... This costs memory in the server side, but sends...
Read more >
How to build a Chat application using Redis
In this tutorial, we will see how to develop real time messaging apps with Flask, Socket.IO and Redis. This example uses Redis Pub/sub ......
Read more >
Let's learn how to to build a chat application with Redis ...
The connected chat users (clients) can send messages to the application ( WebSocket server) and can exchange messages with each other - similar ......
Read more >
Realtime Collaborative Drawing (part 4): Redis PubSub + ...
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.
Read more >
Implementing Caching in Node.js using Redis - Section.io
Caching refers to the process of storing data in a temporary location so that the data can be accessed with minimal resources.
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