Skip to content

Commit

Permalink
refactor: remove unused telegram webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
nreinartz committed Nov 17, 2023
1 parent 4d33cdd commit 0cb5c30
Showing 1 changed file with 0 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1265,47 +1265,6 @@ public Response deactivateBotAll(@PathParam("botAgentId") String bot, JSONObject

return Response.status(Status.NOT_FOUND).entity(bot + " not found.").build();
}

@POST
@Path("/events/telegram/{token}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Receive an Telegram event")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "") })
public Response telegramEvent(String body, @PathParam("token") String token) {

new Thread(new Runnable() {
@Override
public void run() {

// Identify bot
Bot bot = null;

for (Bot b : getConfig().getBots().values()) {
if (b.getMessenger(ChatService.TELEGRAM) != null) {
bot = b;
}
}
if (bot == null)
System.out.println("cannot relate telegram event to a bot with token: " + token);
System.out.println("telegram event: bot identified: " + bot.getName());

// Handle event
Messenger messenger = bot.getMessenger(ChatService.TELEGRAM);
EventChatMediator mediator = (EventChatMediator) messenger.getChatMediator();
JSONParser jsonParser = new JSONParser(JSONParser.MODE_PERMISSIVE);
JSONObject parsedBody;
try {
parsedBody = (JSONObject) jsonParser.parse(body);
mediator.handleEvent(parsedBody);
} catch (ParseException e) {
e.printStackTrace();
}
}
}).start();

return Response.status(200).build();
}
}

public void checkRoutineTrigger(BotConfiguration botConfig, JSONObject j, BotAgent botAgent, String botFunctionId,
Expand Down

0 comments on commit 0cb5c30

Please sign in to comment.