0

I'm built a telegram bot for the groups.When the bot is added to the group, it will delete messages containing ads.How can I change the bot to work for only 30 days in each group and then stop it? That means, for example, today's bot is added to group 1 and the next week the bot is added to group 2; I need to change the bot to stop the 30 days in group 1 and stop it in group 2 for another 37 days. How can I do that?

Sajjad
  • 41
  • 1
  • 4
  • 13
  • Possible duplicate of [How to create a telegram bot that only works for 30 days per user and then stops there?](https://stackoverflow.com/questions/46194007/how-to-create-a-telegram-bot-that-only-works-for-30-days-per-user-and-then-stops) – nostradamus Sep 20 '17 at 07:29

2 Answers2

0

You can't know how long your bot had been added to group at this time. :(

You need to log it to your own database, and there is leaveChat method if you need it.

Sean Wei
  • 7,433
  • 1
  • 19
  • 39
0

Simply, all you need is a database at the back-end. Just store the group_id and join_date in each row.

At any time, you can query your database. If more than 30 days has passed join_date, stop the bot or leave the group.

You can also use any other storage rather than a database. A file, index, etc.

Ali Hashemi
  • 3,158
  • 3
  • 34
  • 48