skip to Main Content

So I have limited experience in Java (have some experience with APIs but little experience making bots or clients). However, I have switched to using Telegram instead of iMessage simply because it’s easier to use and more responsive. I also appreciate the open-source nature and the ability for me to create a bot. But I don’t know much in terms of other languages, and am only a student. I was wondering if it was possible to create a bot that, when a certain string is entered, followed by a term, the bot searches Wikipedia and returns the first page that matches the term (or some exception).

Lofty idea… but I have no idea what I’m doing. Does anyone know if there’s a place I could find a tutorial (not Youtube) or if somebody with more knowledge than me (most people who read this) could teach me? That’d be amazing.

My background:
Processing
AP Computer Science A
Limited API use

TL;DR Wikipedia bot for Telegram, need help.

5

Answers


  1. That is possible when you have a specific search term. You can search Wikipedia when you read this:

    Do try

    To see how to read contents from an url read Java tutorial and then “Java notes v7” book by David J. Eck, section 11.4

    Login or Signup to reply.
  2. It is possible to do it. You can check out this telegram-bot created on github. It’s written in LUA.

    The idea you were thinking about has already been done. There’s a plugin for wikipedia using that bot. I suggest reading the source code and from there try to make sense out of it and then try making another plugin on your own referring to the source codes found in the plugin folder.

    Login or Signup to reply.
  3. The Telegram Bot API is now officially available.

    Resources:

    Login or Signup to reply.
  4. Maybe this Java API is what you are searching for: TelegramBot JavaAPI

    You have to create a class implementing IReceiverService and then something like that:

    public class GetMessage implements IReceiverService {
    
        @Override
        public void received(Message message) {
            switch (message.getMessageType()) {
            case TEXT_MESSAGE:
                String text = message.getMessage().toString();
    
                // Look up Wikipedia with
                // https://en.m.wikipedia.org/wiki/<text>
                // process the response and send it back.
                String wiki = "My processed wiki content.";
    
                Sender.send(message.getSender().getId(), wiki);
    
                break;
            default:
                System.out.println("Ignore received message.");
            }
        }
    }
    
    Login or Signup to reply.
  5. My simple Java API for Telegram bots

    https://github.com/pengrad/java-telegram-bot-api

    compile 'com.github.pengrad:java-telegram-bot-api:3.6.0'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search