From b78a950dda1fa300f09241a5ff49ceaa644aef2a Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Wed, 19 Dec 2018 01:58:52 -0600 Subject: [PATCH] Added YAML config and basic response abilities --- .gitignore | 2 ++ bot_config.yaml.example | 2 ++ empyrion-bot.rb | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 .gitignore create mode 100644 bot_config.yaml.example create mode 100755 empyrion-bot.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4129f9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/bot_config.yaml + diff --git a/bot_config.yaml.example b/bot_config.yaml.example new file mode 100644 index 0000000..4b24371 --- /dev/null +++ b/bot_config.yaml.example @@ -0,0 +1,2 @@ +token: '' + diff --git a/empyrion-bot.rb b/empyrion-bot.rb new file mode 100755 index 0000000..491ddbf --- /dev/null +++ b/empyrion-bot.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +require 'rubygems' +require 'yaml' +require 'telegram/bot' + +conf = YAML.load(File.read("bot_config.yaml")) +token = conf['token'] + +puts 'Bot token: ' + token + +Telegram::Bot::Client.run(token) do |bot| + bot.listen do |message| + case message.text + when '/start' + reply = "This bot will eventually (hopefully) be able retrieve information and pass start/stop commands from/to an Empyrion server, to make life easier for meatbags like you." + puts "Sending #{reply.inspect}" + bot.api.send_message(chat_id: message.chat.id, text: "#{reply}") + when '/srv-start' + reply = "UNAVAILABLE: This command would start the game server if the code were there." + puts "Sending #{reply.inspect}" + bot.api.send_message(chat_id: message.chat.id, text: "#{reply}") + when '/srv-stop' + reply = "UNAVAILABLE: This command would stop the game server if the code were there." + puts "Sending #{reply.inspect}" + bot.api.send_message(chat_id: message.chat.id, text: "#{reply}") + when '/status' + reply = "UNAVAILABLE: This command would provide server status and possibly version... If the code were there." + puts "Sending #{reply.inspect}" + bot.api.send_message(chat_id: message.chat.id, text: "#{reply}") + end + end +end +