Code Monkey home page Code Monkey logo

Comments (9)

mukel avatar mukel commented on May 22, 2024

A bot can remove messages https://stackoverflow.com/a/45285278/5457433 from groups and receive leave/join notifications ... not sure about service messages. It shouldn't be hard to set it up e.g. a bot that deletes all messages. I'll give it a shot.

from telegram.

v-shaal avatar v-shaal commented on May 22, 2024

php-telegram-bot/core#730 I am reffering to this , I am not sure about PHP though

from telegram.

mukel avatar mukel commented on May 22, 2024

Join/left messages are bundled in fields containing the users in Message.
Please try this, couldn't test it, but should work or be very close.

import info.mukel.telegrambot4s.api._
import info.mukel.telegrambot4s.methods._
import info.mukel.telegrambot4s.models._

/**
  * Remove join/left messages from groups.
  */
object GroupBot extends TelegramBot
  with Polling {
  lazy val token = "TOKEN"

  override def receiveMessage(msg: Message): Unit = {
    super.receiveMessage(msg)
    if (msg.newChatMembers.isDefined || msg.leftChatMember.isDefined)
      request(DeleteMessage(msg.source, msg.messageId))
  }
}

GroupBot.run()

from telegram.

v-shaal avatar v-shaal commented on May 22, 2024

Thanks It worked , but only for single group ,when I added the bot in two group it tarted throwing me this error .

ERROR info.mukel.telegrambot4s.clients.AkkaClient - Telegram API exception
info.mukel.telegrambot4s.api.TelegramApiException: Bad Request: message can't be deleted
	at info.mukel.telegrambot4s.clients.AkkaClient.$anonfun$apply$3(AkkaClient.scala:56)
	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:302)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
	at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:140)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1021)
	at java.util.concurrent.ForkJoinPool$WorkQueue.execLocalTasks(ForkJoinPool.java:1046)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1058)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

from telegram.

mukel avatar mukel commented on May 22, 2024

It seems like a permission issue. The bot must be admin or have permission to delete messages.
https://core.telegram.org/bots/api#deletemessage

from telegram.

mukel avatar mukel commented on May 22, 2024

Any updates on this?

from telegram.

v-shaal avatar v-shaal commented on May 22, 2024

works perfect after giving permission.

from telegram.

sajadi1846 avatar sajadi1846 commented on May 22, 2024

hi . my bot delete the join and left service messages in my group but speed of deleting is so slow . when i add 50 person in one action with telegraph 50 service message apear in room and about 30 seconds for delete this 50 service messages with bot . my bot writen in php . see my code please . can you help me for solve this problem ? thanks

from telegram.

sajadi1846 avatar sajadi1846 commented on May 22, 2024

@$newmember = $result->message->new_chat_member->id;
@$leftmember = $result->message->left_chat_member->id;
@$gpid = $result->message->chat->id;
@$messageid = $result->message->message_id;
$telegram = new telegram(TOKEN,HOST,USERNAME,PASSWORD,DBNAME);
if(!empty($newmember)|| !empty($leftmember)){
$telegram->deleteMessage($gpid,$messageid);
die();
}

from telegram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.