当前位置: 首页>>代码示例>>Java>>正文


Java Update.hasMessage方法代码示例

本文整理汇总了Java中org.telegram.telegrambots.api.objects.Update.hasMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Update.hasMessage方法的具体用法?Java Update.hasMessage怎么用?Java Update.hasMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.telegram.telegrambots.api.objects.Update的用法示例。


在下文中一共展示了Update.hasMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MessageHandle

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
public static void MessageHandle(TelegramBot tgb, Update msg){
	MessageHandle.msg = msg;
	MessageHandle.tgb = tgb;
	if(msg.hasMessage()){
		if(msg.getMessage().hasText()){
			switch(msg.getMessage().getText().toUpperCase()){
				case "IV":
					showIV();
					break;
				case "GAMEID":
					showGameId();
					break;
			}
		}
	}
}
 
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:17,代码来源:MessageHandle.java

示例2: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
public void onUpdateReceived(Update update) {
	if (update.hasMessage() && update.getMessage().hasPhoto()) {
		Message message = update.getMessage();
		long chatId = message.getChatId();
		// get the last photo - it seems to be the bigger one
		List<PhotoSize> photos = message.getPhoto();
		PhotoSize photo = photos.get(photos.size() - 1);
		String id = photo.getFileId();
		try {
			GetFile getFile = new GetFile();
			getFile.setFileId(id);
			String filePath = getFile(getFile).getFileUrl(getBotToken());
			// TODO: cache images?
			logger.info("== DOWNLOADING IMAGE " + filePath);
			URL url = new URL(filePath);
			String caption = Classifier.classify(url.openStream());
			logger.info("Caption for image " + filePath + ":\n" + caption);
			sendPhotoMessage(chatId, id, caption);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:jesuino,项目名称:java-ml-projects,代码行数:24,代码来源:ClassifierBot.java

示例3: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public void onUpdateReceived(Update update) {
    if (update.hasMessage()) {
        Message message = update.getMessage();
        System.out.println(message);
        List<User> newUsers = update.getMessage().getNewChatMembers();
        if (newUsers != null) {
            String welcomeMessage = "Bienvenido al grupo Java Studio: ";

            for (User newUser : newUsers) {
                String user = newUser.getUserName().equals("null") ? newUser.getFirstName()
                        : "@" + newUser.getUserName();
                welcomeMessage += user + " ";
            }
            SendMessage welcomeSendMessage = new SendMessage()
                    .setChatId(message.getChatId())
                    .setText(welcomeMessage);
            try {
                sendMessage(welcomeSendMessage);
            } catch (TelegramApiException ex) {
                Logger.getLogger(CoffeeAndyBot.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }
}
 
开发者ID:Java-Studio-Telegram-Group,项目名称:Coffee_AndyBot,代码行数:27,代码来源:CoffeeAndyBot.java

示例4: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public synchronized void onUpdateReceived(final Update update) {
	if (update.hasMessage()) {
		final Message message = update.getMessage();

		Thread processThread = new Thread(() -> {
			TgContextHolder.setupContext(message);
			TgContext tgContext = TgContextHolder.currentContext();

			synchronized (tgContext) {
				try {
					messageHandler.handleMessage(message, tgContext);
				}catch (TgBotMessageHandleException e) {
					send(tgContext.getChatId(), e.getMessage());
				}
			}
		});
		processThread.setName("TgRequest");
		processThread.setDaemon(true);
		processThread.start();
	}
}
 
开发者ID:enoy19,项目名称:spring-tg,代码行数:23,代码来源:TgBot.java

示例5: MessageHandle

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
public static void MessageHandle(TelegramBot tgb, Update msg){
	MessageHandle.msg = msg;
	MessageHandle.tgb = tgb;	
	if(msg.getMessage().getFrom().getId() == 123078226){
		if(msg.hasMessage()){
			if(msg.getMessage().hasText()){					
				String line =  msg.getMessage().getText().replace(" ", "");
				Pattern r = Pattern.compile("\\-*[0-9]+\\.[0-9]+,\\-*[0-9]+\\.[0-9]+");
				if (r.matcher(line).find()) {
					String[] pinfo = line.split(",");
					try {
						double x,y;
						NumberFormat df = NumberFormat.getNumberInstance();
						df.setMaximumFractionDigits(6);
						x = Float.parseFloat(df.format(Float.parseFloat(pinfo[0])));
						y = Float.parseFloat(df.format(Float.parseFloat(pinfo[1])));
						findMon(Example.go.get(0),x,y);
					}catch(Exception ex){}
				}
				
				switch(msg.getMessage().getText().toUpperCase()){
					case "IV":
						showIV();
						break;
					case "GAMEID":
						showGameId();
						break;
					case "STOP":
						Example.go.get(0).setLocation(22.2821181,114.1510632,1);
						stop();
						break;
				}
			}
		}
	}
	if(msg.getMessage().hasLocation()){
		findMon(Example.go.get(0),msg.getMessage().getLocation().getLatitude(),msg.getMessage().getLocation().getLongitude());
	}
}
 
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:40,代码来源:MessageHandle.java

示例6: MessageHandle

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
public static void MessageHandle(TelegramBot tgb, Update msg){
	MessageHandle.msg = msg;
	MessageHandle.tgb = tgb;	
	if(msg.getMessage().getFrom().getId() == 123078226){
		if(msg.hasMessage()){
			if(msg.getMessage().hasText()){					
				String line =  msg.getMessage().getText().replace(" ", "");
				Pattern r = Pattern.compile("\\-*[0-9]+\\.[0-9]+,\\-*[0-9]+\\.[0-9]+");
				if (r.matcher(line).find()) {
					String[] pinfo = line.split(",");
					try {
						double x,y;
						NumberFormat df = NumberFormat.getNumberInstance();
						df.setMaximumFractionDigits(6);
						x = Float.parseFloat(df.format(Float.parseFloat(pinfo[0])));
						y = Float.parseFloat(df.format(Float.parseFloat(pinfo[1])));
						findMon(Example.go.get(0),x,y);
					}catch(Exception ex){}
				}
				
				switch(msg.getMessage().getText().toUpperCase()){
					case "IV":
						showIV();
						break;
					case "GAMEID":
						showGameId();
						break;
				}
			}
		}
	}
	if(msg.getMessage().hasLocation()){
		findMon(Example.go.get(0),msg.getMessage().getLocation().getLatitude(),msg.getMessage().getLocation().getLongitude());
	}
}
 
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:36,代码来源:MessageHandle.java

示例7: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override

	public void onUpdateReceived(Update update) {
		System.out.println(update.getMessage());
		if(update.hasChannelPost()){
			
		}
		if(update.hasMessage()){
			MessageHandle.MessageHandle(this,update);
		}
	}
 
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:12,代码来源:TelegramBot.java

示例8: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
public void onUpdateReceived(Update update) {
	
	if(update.hasMessage()) {
		Message message = update.getMessage();
		String[] command = message.getText().split(" ");

		if(command[0].startsWith("/") && commandHash.containsKey(command[0])) {
			commandHash.get(command[0]).run(update, this);
			logger.write(update);
		} 
		
		else {
			SendMessage sm = new SendMessage();
			sm.setChatId(update.getMessage().getChatId());

			sm.setParseMode(ParseMode.HTML);
			
			sm.setText("Comando Inválido. Digite <b>/ajuda</b> para a lista de comandos.");
			try {
				sendMessage(sm);
			} catch (TelegramApiException e) {
				e.printStackTrace();
			}
		}
		
	}
	
}
 
开发者ID:InsightLab,项目名称:telegram-bots,代码行数:29,代码来源:QualisBot.java

示例9: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public void onUpdateReceived(Update update) {
	// TODO Auto-generated method stub
	System.out.println("Received msg");
	if (update.hasMessage() && update.getMessage().hasText()) {
		String text = update.getMessage().getText().toLowerCase();
		SendMessage message = new SendMessage();
		message.setChatId(update.getMessage().getChatId());
		//write everything in lowercase in the contains
		if(text.equals("/license") || text.equals("/license"+this.getBotUsername())){
			message.setText("Welcome!\nThis bot is a program which is available under the MIT license at https://github.com/Bergiu/TelegramEntenBot");
		}
		else if(text.contains("ente")){
			message.setText("*QUACK!*");
		// } else if (text.contains("bla")){
		// 	message.setText("*BLUB!*");
		// } else if (text.contains("kuh")){
		// 	message.setText("*MUUHH!*");
		}
		else if(text.contains("foss")){
			message.setText("*FOOOOOOOSSSS <3!*");
		}else if (text.contains("git") || text.contains("love")){
			message.setText("*<3*");
		} else {
			return;
		}
		message.setParseMode("markdown");
		try {
			sendMessage(message); // Call method to send the message
		} catch (TelegramApiException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:Bergiu,项目名称:TelegramEntenBot,代码行数:35,代码来源:EntenBot.java

示例10: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public void onUpdateReceived(Update update) {
	if (update.hasMessage()) {
		if (update.getMessage().getText().startsWith("/start")) {
			startQuiz(update);
		} else if (update.getMessage().getText().startsWith("/stop")) {
			quizInterface.endGame(update.getMessage().getChatId());
		}
	} else if (update.hasCallbackQuery()) {
		answerQuestion(update);
	}

}
 
开发者ID:argo2445,项目名称:QBot,代码行数:14,代码来源:QuizBot.java

示例11: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public final void onUpdateReceived(Update update) {
    if (update.hasMessage()) {
        Message message = update.getMessage();
        if (message.isCommand() && !filter(message)) {
            if (commandRegistry.executeCommand(this, message)) {
                return;
            }
        }
    }
    processNonCommandUpdate(update);
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:13,代码来源:TelegramLongPollingCommandBot.java

示例12: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public void onUpdateReceived(Update update) {
    if (update.hasMessage()) {
        handleMessage(update.getMessage());
    } else if (update.hasCallbackQuery()) {
        handleCallbackQuery(update.getCallbackQuery());
    } else {
        log.info("Unsupported update: {}", update.toString());
    }
}
 
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:11,代码来源:MensaBot.java

示例13: MessageHandle

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
public static void MessageHandle(TelegramBot tgb, Update msg){
	MessageHandle.msg = msg;
	MessageHandle.tgb = tgb;	
	if(msg.getMessage().getFrom().getId() == 123078226){
		if(msg.hasMessage()){
			if(msg.getMessage().hasText()){					
				String line =  msg.getMessage().getText().replace(" ", "");
				Pattern r = Pattern.compile("\\-*[0-9]+\\.[0-9]+,\\-*[0-9]+\\.[0-9]+");
				if (r.matcher(line).find()) {
					String[] pinfo = line.split(",");
					try {
						double x,y;
						NumberFormat df = NumberFormat.getNumberInstance();
						df.setMaximumFractionDigits(6);
						x = Float.parseFloat(df.format(Float.parseFloat(pinfo[0])));
						y = Float.parseFloat(df.format(Float.parseFloat(pinfo[1])));
						findMon(Example.go.get(0),x,y);
					}catch(Exception ex){}
				}
				
				switch(msg.getMessage().getText().toUpperCase()){
					case "IV":
						showIV();
						break;
					case "GAMEID":
						showGameId();
						break;
					case "STOP":
						Example.go.get(0).setLocation(22.2821181,114.1510632,1);
						stop();
						break;
					case "CATCH":
						catchMon(Example.go.get(0),msg);
				}
			}
		}
	}
	if(msg.getMessage().hasLocation()){
		findMon(Example.go.get(0),msg.getMessage().getLocation().getLatitude(),msg.getMessage().getLocation().getLongitude());
	}
}
 
开发者ID:slgphantom,项目名称:yearyearyear,代码行数:42,代码来源:MessageHandle.java

示例14: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public void onUpdateReceived(Update update) {
    if(update.hasMessage() && update.getMessage().hasText()) {
        //TODO
    }
}
 
开发者ID:franziheck,项目名称:Paulette,代码行数:7,代码来源:Paulette.java

示例15: onUpdateReceived

import org.telegram.telegrambots.api.objects.Update; //导入方法依赖的package包/类
@Override
public void onUpdateReceived(Update update) {
	
	if(Database.hasStudent(update.getMessage().getFrom().getId()))
		try {
			sendMessage(new SendMessage().setText("I am your personal school assistant!").setChatId(update.getMessage().getChatId()));
			sendMessage(new SendMessage().setText("Say \"Help\" for a list of commands, or just say what you need!").setChatId(update.getMessage().getChatId()));
		} catch (TelegramApiException e) {
			System.err.println("Error sending welcome message:");
			e.printStackTrace();
		}
	
	if(update.hasMessage() && update.getMessage().hasText() && update.getMessage().getChat().getUserName() != null /* <-- this bot isn't useful for group chats */) {
		
		String input = update.getMessage().getText();
		if(input.startsWith("/")) {
			
			//they want to use commands
			
			
		} else {
			
			//they want the human-like assistant
			
		}
		
	}
}
 
开发者ID:calmyourtities,项目名称:school-assistant,代码行数:29,代码来源:SchoolAssistantBot.java


注:本文中的org.telegram.telegrambots.api.objects.Update.hasMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。