Merge Upstream
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -7,3 +7,4 @@ Bot-Kommandoliste.txt
 | 
				
			|||||||
msg.txt
 | 
					msg.txt
 | 
				
			||||||
merge.sh
 | 
					merge.sh
 | 
				
			||||||
miku/plugins/link_warning.lua
 | 
					miku/plugins/link_warning.lua
 | 
				
			||||||
 | 
					luarocks
 | 
				
			||||||
@@ -22,10 +22,12 @@ Mikubot V2 ist freie Software; du darfst ihn modifizieren und weiterverbreiten,
 | 
				
			|||||||
# Für User
 | 
					# Für User
 | 
				
			||||||
## Setup
 | 
					## Setup
 | 
				
			||||||
### Ubuntu und Debian
 | 
					### Ubuntu und Debian
 | 
				
			||||||
Ubuntu und Debian liefern Luarocks nur für Lua 5.1 aus. Um Luarocks für Lua 5.2 zu verwenden, folge bitte der [Anleitung auf StackOverflow](http://stackoverflow.com/a/20359102).
 | 
					Falls du Ubuntu oder Debian verwendest, kannst du einfach `./install-dependencies.sh` ausführen, damit alles installiert wird. Ergänze dann noch den `bot_api_key` und die `admin`-ID (Bekommst du in Telegram mit `@Mikubot id`) und kopiere die config.lua.example nach config.lua.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Für eine manuelle Installation musst du LuaRocks für 5.2 [selbst kompilieren](http://stackoverflow.com/a/20359102).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Setup
 | 
					### Setup
 | 
				
			||||||
Du benötigst **Lua 5.2+**, eine aktive **Redis-Instanz** und die folgenden **LuaRocks-Module**:
 | 
					Du benötigst **Lua 5.2** (Lua 5.3 funktioniert NICHT!), eine aktive **Redis-Instanz** und die folgenden **LuaRocks-Module**:
 | 
				
			||||||
* luautf8
 | 
					* luautf8
 | 
				
			||||||
* luasocket
 | 
					* luasocket
 | 
				
			||||||
* luasec
 | 
					* luasec
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										29
									
								
								install-dependencies.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										29
									
								
								install-dependencies.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					# Installiert Lua, Luarocks und andere Abhängigkeiten. Sollte auch auf Debian funktionieren.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rocklist="luasocket luasec multipart-post lpeg dkjson redis-lua fakeredis oauth xml feedparser serpent luautf8"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "Dieses Skript ist für Ubuntu, es wird wahrscheinlich auch für Debian funktionieren."
 | 
				
			||||||
 | 
					echo "Dieses Skript benötigt Root-Rechte, um folgende Pakete zu installieren:"
 | 
				
			||||||
 | 
					echo "lua5.2 liblua5.2-dev git libssl-dev fortune-mod fortunes redis-server unzip make"
 | 
				
			||||||
 | 
					echo "Es werden auch Root-Rechte benötigt, um LuaRocks in /usr/local/"
 | 
				
			||||||
 | 
					echo "mit den folgenden Rocks zu installieren:"
 | 
				
			||||||
 | 
					echo $rocklist
 | 
				
			||||||
 | 
					echo "Drücke ENTER, um fortzufahren, oder Strg-C zum Beenden."
 | 
				
			||||||
 | 
					read
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sudo apt-get update
 | 
				
			||||||
 | 
					sudo apt-get install -y lua5.2 liblua5.2-dev git libssl-dev fortune-mod fortunes redis-server unzip make
 | 
				
			||||||
 | 
					git clone http://github.com/keplerproject/luarocks
 | 
				
			||||||
 | 
					cd luarocks
 | 
				
			||||||
 | 
					./configure --lua-version=5.2 --versioned-rocks-dir --lua-suffix=5.2
 | 
				
			||||||
 | 
					make build
 | 
				
			||||||
 | 
					sudo make install
 | 
				
			||||||
 | 
					for rock in $rocklist; do
 | 
				
			||||||
 | 
					    sudo luarocks-5.2 install $rock
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					sudo -k
 | 
				
			||||||
 | 
					cd ..
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "Vorgang beendet! Nutze ./launch.sh, um den Bot zu starten."
 | 
				
			||||||
 | 
					echo "Setze vorher dein Bot-Token in der config.lua.example und kopiere sie nach config.lua."
 | 
				
			||||||
							
								
								
									
										21
									
								
								launch.sh
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								launch.sh
									
									
									
									
									
								
							@@ -1,8 +1,21 @@
 | 
				
			|||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
# Launch Mikubot
 | 
					# Run Mikubot.
 | 
				
			||||||
# Restart Mikubot five seconds after halted.
 | 
					# If none, give an error and a friendly suggestion.
 | 
				
			||||||
 | 
					# If Lua was found, restart Mikubot five seconds after halting each time.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if type lua5.2 >/dev/null 2>/dev/null; then
 | 
				
			||||||
    while true; do
 | 
					    while true; do
 | 
				
			||||||
    lua main.lua
 | 
					        lua5.2 main.lua
 | 
				
			||||||
    echo 'Mikubot wurde gestoppt. ^C zum beenden.'
 | 
					        echo "Mikubot wurde angehalten. ^C zum Beenden."
 | 
				
			||||||
        sleep 5s
 | 
					        sleep 5s
 | 
				
			||||||
    done
 | 
					    done
 | 
				
			||||||
 | 
					elif type lua >/dev/null 2>/dev/null; then
 | 
				
			||||||
 | 
					    while true; do
 | 
				
			||||||
 | 
					        lua main.lua
 | 
				
			||||||
 | 
					        echo "Mikubot wurde angehalten. ^C zum Beenden."
 | 
				
			||||||
 | 
					        sleep 5s
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					    echo "Lua nicht gefunden."
 | 
				
			||||||
 | 
						echo "Falls du Ubuntu verwendest, führe vorher ./install-dependencies.sh aus."
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
@@ -17,6 +17,12 @@ function luarun:init(config)
 | 
				
			|||||||
            return JSON.encode(t, {indent=true})
 | 
					            return JSON.encode(t, {indent=true})
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					    -- Lua 5.2 compatibility.
 | 
				
			||||||
 | 
					    -- "loadstring" was renamed "load" in 5.3.
 | 
				
			||||||
 | 
					    luarun.loadstring = load or loadstring
 | 
				
			||||||
 | 
					    luarun.err_msg = function(x)
 | 
				
			||||||
 | 
					        return 'Error:\n' .. tostring(x)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function luarun:action(msg, config)
 | 
					function luarun:action(msg, config)
 | 
				
			||||||
@@ -35,24 +41,21 @@ function luarun:action(msg, config)
 | 
				
			|||||||
        input = 'return ' .. input
 | 
					        input = 'return ' .. input
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local output, success =
 | 
					    local output, success = luarun.loadstring(
 | 
				
			||||||
        load("local bot = require('miku.bot')\n\z
 | 
					        "local bot = require('miku.bot')\n\z
 | 
				
			||||||
        local bindings = require('miku.bindings')\n\z
 | 
					        local bindings = require('miku.bindings')\n\z
 | 
				
			||||||
        local utilities = require('miku.utilities')\n\z
 | 
					        local utilities = require('miku.utilities')\n\z
 | 
				
			||||||
        local json = require('dkjson')\n\z
 | 
					        local json = require('dkjson')\n\z
 | 
				
			||||||
        local URL = require('socket.url')\n\z
 | 
					        local URL = require('socket.url')\n\z
 | 
				
			||||||
        local http = require('socket.http')\n\z
 | 
					        local http = require('socket.http')\n\z
 | 
				
			||||||
        local https = require('ssl.https')\n\z
 | 
					        local https = require('ssl.https')\n\z
 | 
				
			||||||
        return function (self, msg, config)\n" .. input .. "\nend")
 | 
					        return function (self, msg, config)\n" .. input .. "\nend"
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
    local function err_msg(x)
 | 
					 | 
				
			||||||
        return "Fehler:\n" .. tostring(x)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if output == nil then
 | 
					    if output == nil then
 | 
				
			||||||
        output = success
 | 
					        output = success
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        success, output = xpcall(output(), err_msg, self, msg, config)
 | 
					        success, output = xpcall(output(), luarun.err_msg, self, msg, config)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if output == nil then
 | 
					    if output == nil then
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local utilities = {}
 | 
					local utilities = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
utf8 = require 'lua-utf8'
 | 
					utf8 = require('lua-utf8')
 | 
				
			||||||
ltn12 = require('ltn12')
 | 
					ltn12 = require('ltn12')
 | 
				
			||||||
http = require('socket.http')
 | 
					http = require('socket.http')
 | 
				
			||||||
https = require('ssl.https')
 | 
					https = require('ssl.https')
 | 
				
			||||||
@@ -1137,4 +1137,5 @@ function utilities.fix_utf8(str)
 | 
				
			|||||||
    return string.char(utf8.codepoint(str, 1, -1))
 | 
					    return string.char(utf8.codepoint(str, 1, -1))
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return utilities
 | 
					return utilities
 | 
				
			||||||
		Reference in New Issue
	
	Block a user