Compare commits

..

No commits in common. "0238610cd1202163c74c2dfadc34ba38133dfab7" and "a9ed7aa159d42edaf10b6d4ad111d01f0e24ae41" have entirely different histories.

2 changed files with 6 additions and 32 deletions

View File

@ -5,7 +5,7 @@ import logging
import requests import requests
import re import re
from emoji import demojize from emoji import demojize
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters from telegram.ext import Updater, MessageHandler, Filters
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - \ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - \
%(message)s', level=logging.INFO) %(message)s', level=logging.INFO)
@ -87,15 +87,7 @@ def message_handling(bot, update):
data=params) data=params)
def list_cmd(bot, update):
if update.message.chat.id in config.groups:
params = {"message": "list"}
requests.post("http://localhost:" + str(config.port) + "/post",
data=params)
updater = Updater(token=config.api_key) updater = Updater(token=config.api_key)
dispatcher = updater.dispatcher dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler('list', list_cmd))
dispatcher.add_handler(MessageHandler(Filters.all, message_handling)) dispatcher.add_handler(MessageHandler(Filters.all, message_handling))
updater.start_polling() updater.start_polling()

View File

@ -1,39 +1,21 @@
local http_api = minetest.request_http_api()
function send_messages(res) function send_messages(res)
for message in string.gmatch(res["data"], "[^\n]+") do for message in string.gmatch(res["data"], "[^\n]+") do
if message == "list" then
local x = minetest.get_connected_players()
local text = "List of Players:\n"
for j, i in ipairs(x) do
local text = text .. i.get_player_name(i)
end
http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode",
post_data = {message = text}})
else
minetest.chat_send_all(message) minetest.chat_send_all(message)
end end
end end
end
function main() function main(http_api)
port = minetest.settings:get("chat_server_port") port = minetest.settings:get("chat_server_port")
if port == nil then if port == nil then
port = "9876" port = "9876"
end end
http_api.fetch({url = "http://localhost:" .. port .. "/get"}, send_messages) http_api.fetch({url = "http://localhost:" .. port .. "/get"}, send_messages)
minetest.after(0.5, main) minetest.after(0.5, main, http_api)
end
function dead(player)
http_api.fetch_async({url = "http://localhost:" .. port .. "/sendCode",
post_data = {message = player.get_player_name(player) ..
" died."}})
end end
local http_api = minetest.request_http_api()
if http_api == nil then if http_api == nil then
minetest.log("error", "Chat Mod is not in secure.http_mods or secure.trusted_mods. Exiting.") minetest.log("error", "Chat Mod is not in secure.http_mods or secure.trusted_mods. Exiting.")
else else
main() main(http_api)
end end
minetest.register_on_dieplayer(dead)