First commit of Mikubot

This commit is contained in:
Akamaru 2015-04-14 20:21:23 +02:00
parent 77d7d65412
commit ce629850e2
106 changed files with 725 additions and 1332 deletions

View File

@ -1,6 +1,6 @@
require("./bot/utils") require("./bot/utils")
VERSION = '0.11.2' VERSION = '2.5-reloaded'
-- This function is called when tg receive a msg -- This function is called when tg receive a msg
function on_msg_receive (msg) function on_msg_receive (msg)
@ -76,7 +76,7 @@ local function is_plugin_disabled_on_chat(plugin_name, receiver)
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
print(disabled_plugin) print(disabled_plugin)
if disabled_plugin == plugin_name and disabled then if disabled_plugin == plugin_name and disabled then
local warning = 'Plugin '..disabled_plugin..' is disabled on this chat' local warning = ''
print(warning) print(warning)
send_msg(receiver, warning, ok_cb, false) send_msg(receiver, warning, ok_cb, false)
return true return true

View File

@ -99,7 +99,7 @@ function download_to_file(url, file_name)
file_name = file_name or get_http_file_name(url, headers) file_name = file_name or get_http_file_name(url, headers)
local file_path = "/tmp/"..file_name local file_path = "/home/pi/Mikubot/tmp/"..file_name
print("Saved to: "..file_path) print("Saved to: "..file_path)
file = io.open(file_path, "w+") file = io.open(file_path, "w+")

BIN
pictures/Nii-san.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
pictures/aha.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
pictures/cats/cat1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
pictures/cats/cat2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
pictures/cats/cat3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
pictures/cats/cat4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
pictures/nau.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
pictures/neorame.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
pictures/nyu.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
pictures/sakurasou/jin.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -30,9 +30,9 @@ local function run(msg, matches)
end end
return { return {
description = "9GAG for telegram", description = "9GAG",
usage = "!9gag: Send random image from 9gag", usage = "/9gag",
patterns = {"^!9gag$"}, patterns = {"^/9gag$"},
run = run run = run
} }

13
plugins/afk.lua Normal file
View File

@ -0,0 +1,13 @@
function run(msg, matches)
local user_name = get_name(msg)
return "" .. user_name .. " ist nun AFK"
end
return {
description = "Sagt dass ihr afk seid",
usage = "/afk",
patterns = {
"^/afk(.*)$"
},
run = run
}

13
plugins/aha.png.lua Normal file
View File

@ -0,0 +1,13 @@
function run(msg, matches)
if string.starts(msg.text, "aha.png") then
send_photo(get_receiver(msg), "pictures/aha.png", ok_cb, false)
end
end
return {
description = "Aha",
usage = "aha.png",
patterns = {"^aha.png"},
run = run
}

15
plugins/baka_bot.lua Normal file
View File

@ -0,0 +1,15 @@
function run(msg, matches)
return "Gomen'nasai 😣"
end
return {
description = "",
usage = "",
patterns = {"^baka bot",
"Baka bot",
"baka Bot",
"Baka Bot",
"BAKA BOT"},
run = run
}

15
plugins/barusamikosu.lua Normal file
View File

@ -0,0 +1,15 @@
function run(msg, matches)
if string.starts(msg.text, '/barusamiko') or string.starts(msg.text, "/barusamikosu") or string.starts(msg.text, "/Balsamiko Essig") then
send_photo(get_receiver(msg), "pictures/luckystar/barusamikosu.jpg", ok_cb, false)
end
end
return {
description = "Balsamiko Essig!",
usage = "/barusamiko",
patterns = {"^/barusamiko",
"^/barusamikosu",
"^/Balsamiko Essig"},
run = run
}

View File

@ -11,7 +11,7 @@ function getRandomButts(attempt)
-- The OpenBoobs API sometimes returns an empty array -- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then if not data and attempt < 10 then
print('Cannot get that butts, trying another ones...') print('Keine Butts gefunden!')
return getRandomButts(attempt) return getRandomButts(attempt)
end end
@ -29,7 +29,7 @@ function getRandomBoobs(attempt)
-- The OpenBoobs API sometimes returns an empty array -- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then if not data and attempt < 10 then
print('Cannot get that boobs, trying another ones...') print('Keine Boobs gefunden!')
return getRandomBoobs(attempt) return getRandomBoobs(attempt)
end end
@ -39,11 +39,11 @@ end
function run(msg, matches) function run(msg, matches)
local url = nil local url = nil
if matches[1] == "!boobs" then if matches[1] == "/boobs" then
url = getRandomBoobs() url = getRandomBoobs()
end end
if matches[1] == "!butts" then if matches[1] == "/butts" then
url = getRandomButts() url = getRandomButts()
end end
@ -51,19 +51,19 @@ function run(msg, matches)
local receiver = get_receiver(msg) local receiver = get_receiver(msg)
send_photo_from_url(receiver, url) send_photo_from_url(receiver, url)
else else
return 'Error getting boobs/butts for you, please try again later.' return 'Keine Boobs/Butts gefunden.'
end end
end end
return { return {
description = "Gets a random boobs or butts pic", description = "Sendet ein zufälliges Boobs/Butts Bild",
usage = { usage = {
"!boobs: Get a boobs NSFW image. 🔞", "/boobs",
"!butts: Get a butts NSFW image. 🔞" "/butts"
}, },
patterns = { patterns = {
"^!boobs$", "^/boobs$",
"^!butts$" "^/butts$"
}, },
run = run run = run
} }

View File

@ -1,50 +0,0 @@
function getBTCX(amount,currency)
-- Do request on bitcoinaverage, the final / is critical!
local res,code = https.request("https://api.bitcoinaverage.com/ticker/global/"..currency.."/")
if code~= 200 then return nil end
local data = json:decode(res)
-- Easy, it's right there
text = "BTC/"..currency..'\n'..'Buy: '..data.ask..'\n'..'Sell: '..data.bid
-- If we have a number as second parameter, calculate the bitcoin amount
if amount~=nil then
btc = tonumber(amount) / tonumber(data.ask)
text = text.."\n "..currency .." "..amount.." = BTC "..btc
end
return text
end
function run(msg, matches)
vardump(matches)
local cur = 'EUR'
local amt = nil
-- Get the global match out of the way
if matches[1] == "!btc" then return getBTCX(amt,cur) end
if matches[2]~=nil then
-- There is a second match
amt = matches[2]
cur = string.upper(matches[1])
else
-- Just a EUR or USD param
cur = string.upper(matches[1])
end
return getBTCX(amt,cur)
end
return {
description = "Bitcoin global average market value (in EUR or USD)",
usage = "!btc [EUR|USD] [amount]",
patterns = {
"^!btc$",
"^!btc ([Ee][Uu][Rr])$",
"^!btc ([Uu][Ss][Dd])$",
"^!btc (EUR) (%d+[%d%.]*)$",
"^!btc (USD) (%d+[%d%.]*)$"
},
run = run
}

View File

@ -1,106 +0,0 @@
do
local BASE_URL = "https://bugzilla.mozilla.org/rest/"
function bugzilla_login()
local url = BASE_URL.."login?login=" .. _config.bugzilla.username .. "&password=" .. _config.bugzilla.password
print("accessing " .. url)
local res,code = https.request( url )
data = json:decode(res)
return data
end
function bugzilla_check(id)
-- data = bugzilla_login()
vardump(data)
local url = BASE_URL.."bug/" .. id .. "?api_key=" .. _config.bugzilla.apikey
-- print(url)
local res,code = https.request( url )
data = json:decode(res)
return data
end
function bugzilla_listopened(email)
local url = BASE_URL.."bug?include_fields=id,summary,status,whiteboard,resolution&email1=" .. email .. "&email2=" .. email .. "&emailassigned_to2=1&emailreporter1=1&emailtype1=substring&emailtype2=substring&f1=bug_status&f2=bug_status&n1=1&n2=1&o1=equals&o2=equals&resolution=---&v1=closed&v2=resolved&api_key=" .. _config.bugzilla.apikey
local res,code = https.request( url )
print(res)
local data = json:decode(res)
return data
end
function run(msg, matches)
local response = ""
if matches[1] == "status" then
data = bugzilla_check(matches[2])
vardump(data)
if data.error == true then
return "Sorry, API failed with message: " .. data.message
else
response = "Bug #"..matches[1]..":\nReporter: "..data.bugs[1].creator
response = response .. "\n Last update: "..data.bugs[1].last_change_time
response = response .. "\n Status: "..data.bugs[1].status.." "..data.bugs[1].resolution
response = response .. "\n Whiteboard: "..data.bugs[1].whiteboard
response = response .. "\n Access: https://bugzilla.mozilla.org/show_bug.cgi?id=" .. matches[1]
print(response)
end
elseif matches[1] == "list" then
data = bugzilla_listopened(matches[2])
vardump(data)
if data.error == true then
return "Sorry, API failed with message: " .. data.message
else
-- response = "Bug #"..matches[1]..":\nReporter: "..data.bugs[1].creator
-- response = response .. "\n Last update: "..data.bugs[1].last_change_time
-- response = response .. "\n Status: "..data.bugs[1].status.." "..data.bugs[1].resolution
-- response = response .. "\n Whiteboard: "..data.bugs[1].whiteboard
-- response = response .. "\n Access: https://bugzilla.mozilla.org/show_bug.cgi?id=" .. matches[1]
local total = table.map_length(data.bugs)
print("total bugs: " .. total)
response = "There are " .. total .. " number of bug(s) assigned/reported by " .. matches[2]
if total > 0 then
response = response .. ": "
for tableKey, bug in pairs(data.bugs) do
response = response .. "\n #" .. bug.id
response = response .. "\n Status: " .. bug.status .. " " .. bug.resolution
response = response .. "\n Whiteboard: " .. bug.whiteboard
response = response .. "\n Summary: " .. bug.summary
end
end
end
end
return response
end
-- (table)
-- [bugs] = (table)
-- [1] = (table)
-- [status] = (string) ASSIGNED
-- [id] = (number) 927704
-- [whiteboard] = (string) [approved][full processed]
-- [summary] = (string) Budget Request - Arief Bayu Purwanto - https://reps.mozilla.org/e/mozilla-summit-2013/
-- [2] = (table)
-- [status] = (string) ASSIGNED
-- [id] = (number) 1049337
-- [whiteboard] = (string) [approved][full processed][waiting receipts][waiting report and photos]
-- [summary] = (string) Budget Request - Arief Bayu Purwanto - https://reps.mozilla.org/e/workshop-firefox-os-pada-workshop-media-sosial-untuk-perubahan-1/
-- total bugs: 2
return {
description = "Lookup bugzilla status update",
usage = "/bot bugzilla [bug number]",
patterns = {
"^/bugzilla (status) (.*)$",
"^/bugzilla (list) (.*)$"
},
run = run
}
end

View File

@ -17,13 +17,13 @@ local function enable_channel(receiver)
end end
if _config.disabled_channels[receiver] == nil then if _config.disabled_channels[receiver] == nil then
return 'Channel isn\'t disabled' return 'Channel ist nicht deaktiviert!'
end end
_config.disabled_channels[receiver] = false _config.disabled_channels[receiver] = false
save_config() save_config()
return "Channel reenabled" return "Channel wieder aktiviert!"
end end
local function disable_channel( receiver ) local function disable_channel( receiver )
@ -34,7 +34,7 @@ local function disable_channel( receiver )
_config.disabled_channels[receiver] = true _config.disabled_channels[receiver] = true
save_config() save_config()
return "Channel disabled" return "Channel deaktiviert!"
end end
local function pre_process(msg) local function pre_process(msg)
@ -42,7 +42,7 @@ local function pre_process(msg)
-- If is sudo can reeanble the channel -- If is sudo can reeanble the channel
if is_sudo(msg) then if is_sudo(msg) then
if msg.text == "!channel enable" then if msg.text == "/channel enable" then
enable_channel(receiver) enable_channel(receiver)
end end
end end
@ -67,13 +67,11 @@ local function run(msg, matches)
end end
return { return {
description = "Plugin to manage channels. Enable or disable channel.", description = "",
usage = { usage = {""},
"!channel enable: enable current channel",
"!channel disable: disable current channel" },
patterns = { patterns = {
"^!channel? (enable)", "^/channel? (enable)",
"^!channel? (disable)" }, "^/channel? (disable)" },
run = run, run = run,
privileged = true, privileged = true,
pre_process = pre_process pre_process = pre_process

View File

@ -4,10 +4,10 @@ function run(msg, matches)
end end
return { return {
description = "Simplest plugin ever!", description = "Wiederholt euch",
usage = "!echo [whatever]: echoes the msg", usage = "/echo [Satz]",
patterns = { patterns = {
"^!echo (.*)$" "^/echo (.*)$"
}, },
run = run run = run
} }

14
plugins/emoticons.lua Normal file
View File

@ -0,0 +1,14 @@
function run(msg, matches)
if matches[1] == "/emoticons" then
return '😄😃😀😊☺😉😍😘😚😗😙😜😝😛😳😁😔😌😒😞😣😢😂😭😪😥😰😅😓😩😫😨😱😠😡😤😖😆😋😷😎😴😵😲😟😦😧😈👿😮😬😐😕😯😶😇😏😑👲👳👮👷💂👶👦👧👨👩👴👵👱👼👸😺😸😻😽😼🙀😿😹😾👹👺🙈🙉🙊💀👽💩🔥✨🌟💫💥💢💦💧💤💨👂👀👃👅👄👍👎👌👊✊✌👋✋👐👆👇👉👈🙌🙏☝👏💪🚶🏃💃👫👪👬👭💏💑👯🙆🙅💁🙋💆💇💅👰🙎🙍🙇🎩👑👒👟👞👡👠👢👕👔👚👗🎽👖👘👙💼👜👝👛👓🎀🌂💄💛💙💜💚❤💔💗💓💕💖💞💘💌💋💍💎👤👥💬👣💭🐶🐺🐱🐭🐹🐰🐸🐯🐨🐻🐷🐽🐮🐗🐵🐒🐴🐑🐘🐼🐧🐦🐤🐥🐣🐔🐍🐢🐛🐝🐜🐞🐌🐙🐚🐠🐟🐬🐳🐋🐄🐏🐀🐃🐅🐇🐉🐎🐐🐓🐕🐖🐁🐂🐲🐡🐊🐫🐪🐆🐈🐩🐾💐🌸🌷🍀🌹🌻🌺🍁🍃🍂🌿🌾🍄🌵🌴🌲🌳🌰🌱🌼🌐🌞🌝🌚🌑🌒🌓🌔🌕🌖🌗🌘🌜🌛🌙🌍🌎🌏🌋🌌🌠⭐🌀🌁🌈🌊🎍💝🎎🎒🎓🎏🎆🎇🎐🎑🎃👻🎅🎄🎁🎋🎉🎊🎈🎌🔮🎥📷📹📼💿📀💽💾💻📱☎📞📟📠📡📺📻🔊🔉🔈🔇🔔🔕📢📣⏳⌛⏰⌚🔓🔒🔏🔐🔑🔎💡🔦🔆🔅🔌🔋🔍🛁🛀🚿🚽🔧🔩🔨🚪🚬💣🔫🔪💊💉💰💴💵💷💶💳💸📲📧📥📤✉📩📨📯📫📪📬📭📮📦📝📄📃📑📊📈📉📜📋📅📆📇📁📂✂📌📎✒📏📐📕📗📘📙📓📔📒📚📖🔖📛🔬🔭📰🎨🎬🎤🎧🎼🎵🎶🎹🎻🎺🎷🎸👾🎮🃏🎴🀄🎲🎯🏈🏀⚽🎾🎱🏉🎳⛳🚵🚴🏁🏇🏆🎿🏂🏊🏄🎣☕🍵🍶🍼🍺🍻🍸🍹🍷🍴🍕🍔🍟🍗🍖🍝🍛🍤🍱🍣🍥🍙🍘🍚🍜🍲🍢🍡🍳🍞🍩🍮🍦🍨🍧🎂🍰🍪🍫🍬🍭🍯🍎🍏🍊🍋🍒🍇🍉🍓🍑🍈🍌🍐🍍🍠🍆🍅🌽🏠🏡🏫🏢🏣🏥🏦🏪🏩🏨💒⛪🏬🏤🌇🌆🏯🏰⛺🏭🗼🗾🗻🌄🌅🌃🗽🌉🎠🎡⛲🎢🚢⛵🚤🚣⚓🚀✈💺🚁🚂🚊🚉🚞🚆🚄🚅🚈🚇🚝🚋🚃🚎🚌🚍🚙🚘🚗🚕🚖🚛🚚🚨🚓🚔🚒🚑🚐🚲🚡🚟🚠🚜💈🚏🎫🚦🚥⚠🚧🔰⛽🏮🎰♨🗿🎪🎭📍🚩🇯🇵🇰🇷🇩🇪🇨🇳🇺🇸🇫🇷🇪🇸🇮🇹🇷🇺🇬🇧1⃣2⃣3⃣4⃣5⃣6⃣7⃣8⃣9⃣0⃣🔟🔢#⃣🔣⬆️⬇️⬅️➡️🔠🔡🔤↗️↖️↘️↙️↔️↕️🔄◀️▶️🔼🔽↩️↪️ℹ️⏪⏩⏫⏬⤵️⤴️🆗🔀🔁🔂🆕🆙🆒🆓🆖📶🎦🈁🈯️🈳🈵🈴🈲🉐🈹🈺🈶🈚️🚻🚹🚺🚼🚾🚰🚮🅿️♿️🚭🈷🈸🈂Ⓜ️🛂🛄🛅🛃🉑㊙️㊗️🆑🆘🆔🚫🔞📵🚯🚱🚳🚷🚸⛔️✳️❇️❎✅✴️💟🆚📳📴🅰🅱🆎🅾💠➿♻️♈️♉️♊️♋️♌️♍️♎️♏️♐️♑️♒️♓️⛎🔯🏧💹💲💱©®™❌‼️⁉️❗️❓❕❔⭕️🔝🔚🔙🔛🔜🔃🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕖🕗🕘🕙🕚🕡🕢🕣🕤🕥🕦✖️➕➖➗♠️♥️♣️♦️💮💯✔️☑️🔘🔗➰〰〽️🔱◼️◻️◾️◽️▪️▫️🔺🔲🔳⚫️⚪️🔴🔵🔻⬜️⬛️🔶🔷🔸🔹'
end
end
return {
description = "Sendet alle Emoticons",
usage = "/emoticons",
patterns = {"^/emoticons"},
run = run
}

View File

@ -1,35 +0,0 @@
do
function getEURUSD(usd)
local b = http.request("http://webrates.truefx.com/rates/connect.html?c=EUR/USD&f=csv&s=n")
local rates = b:split(", ")
local symbol = rates[1]
local timestamp = rates[2]
local sell = rates[3]..rates[4]
local buy = rates[5]..rates[6]
text = symbol..'\n'..'Buy: '..buy..'\n'..'Sell: '..sell
if usd then
eur = tonumber(usd) / tonumber(buy)
text = text.."\n "..usd.."USD = "..eur.."EUR"
end
return text
end
function run(msg, matches)
if matches[1] == "!eur" then
return getEURUSD(nil)
end
return getEURUSD(matches[1])
end
return {
description = "EURUSD market value",
usage = "!eur [USD]",
patterns = {
"^!eur$",
"^!eur (%d+[%d%.]*)$",
},
run = run
}
end

11
plugins/facepalm.lua Normal file
View File

@ -0,0 +1,11 @@
function run(msg, matches)
send_document(get_receiver(msg), "sticker/facepalm.webp", ok_cb, false)
end
return {
description = "Facepalm",
usage = "/facepalm",
patterns = {"^/facepalm",
"^/Facepalm"},
run = run
}

View File

@ -1,24 +0,0 @@
do
function get_fortunes_uc3m()
local i = math.random(0,178) -- max 178
local web = "http://www.gul.es/fortunes/f"..i
local b, c, h = http.request(web)
return b
end
function run(msg, matches)
return get_fortunes_uc3m()
end
return {
description = "Fortunes from Universidad Carlos III",
usage = "!uc3m",
patterns = {
"^!uc3m$"
},
run = run
}
end

View File

@ -1,94 +0,0 @@
local _file_values = './data/values.lua'
function read_file_values( )
local f = io.open(_file_values, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
print ('Created value file '.._file_values)
serialize_to_file({}, _file_values)
else
print ('Values loaded: '.._file_values)
f:close()
end
return loadfile (_file_values)()
end
_values = read_file_values()
function fetch_value(chat, value_name)
-- Chat non exists
if _values[chat] == nil then
return nil
end
if value_name == nil then
return nil
end
local value = _values[chat][value_name]
return value
end
function get_value(chat, value_name)
-- If chat values is empty
if (_values[chat] == nil) then
return "There isn't any data"
end
-- If there is not value name, return all the values.
if (value_name == nil ) then
local text = ""
for key,value in pairs(_values[chat]) do
text = text..key.." = "..value.."\n"
end
return text
end
local value = _values[chat][value_name]
if ( value == nil) then
return "Can't find "..value_name
end
return value_name.." = "..value
end
function run(msg, matches)
local chat_id = tostring(msg.to.id)
if matches[1] == "!get" then
return get_value(chat_id, nil)
end
return get_value(chat_id, matches[1])
end
function lex(msg)
if msg.text then
local text = msg.text
local chat_id = tostring(msg.to.id)
local s, e = text:find("%$%a+")
if s then
local var = text:sub(s + 1, e)
local value = fetch_value(chat_id, var)
if (value == nil) then
value = "(unknown value " .. var .. ")"
end
msg.text = text:sub(0, s - 1) .. value .. text:sub(e + 1)
end
end
return msg
end
return {
description = "Retrieves variables saved with !set",
usage = "!get (value_name): Returns the value_name value.",
patterns = {
"^!get (%a+)$",
"^!get$"},
run = run,
pre_process = lex
}

View File

@ -49,25 +49,25 @@ function run(msg, matches)
end end
if not gif_url then if not gif_url then
return "Error: GIF not found" return "Kein GIF gefunden!"
end end
local receiver = get_receiver(msg) local receiver = get_receiver(msg)
send_document_from_url(receiver, gif_url) send_document_from_url(receiver, gif_url)
return "Preparing to make you laugh" return "Einen Moment, GIF wird hochgeladen."
end end
return { return {
description = "GIFs from telegram with Giphy API", description = "Sucht und sendet ein GIF von Giphy",
usage = { usage = {
"!gif (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.", "/gif (Begriff)",
"!giphy (term): Search and sends GIF from Giphy. If no param, sends a trending GIF." "/giphy (Begriff)"
}, },
patterns = { patterns = {
"^!gif$", "^/gif$",
"^!gif (.*)", "^/gif (.*)",
"^!giphy (.*)", "^/giphy (.*)",
"^!giphy$" "^/giphy$"
}, },
run = run run = run
} }

View File

@ -28,10 +28,10 @@ function run(msg, matches)
end end
return { return {
description = "Searches Google and send results", description = "Durchsucht Google und sendet die ersten 5 Ergebnisse",
usage = "!google [terms]: Searches Google and send results", usage = "/google [Begriff]",
patterns = { patterns = {
"^!google (.*)$", "^/google (.*)$",
"^%.[g|G]oogle (.*)$" "^%.[g|G]oogle (.*)$"
}, },
run = run run = run

View File

@ -1,28 +0,0 @@
do
function run(msg, matches)
local lat = matches[1]
local lon = matches[2]
local receiver = get_receiver(msg)
local zooms = {16, 18}
local urls = {}
for i = 1, #zooms do
local zoom = zooms[i]
local url = "http://maps.googleapis.com/maps/api/staticmap?zoom=" .. zoom .. "&size=600x300&maptype=roadmap&center=" .. lat .. "," .. lon .. "&markers=color:blue%7Clabel:X%7C" .. lat .. "," .. lon
table.insert(urls, url)
end
send_photos_from_url(receiver, urls)
return "www.google.es/maps/place/@" .. lat .. "," .. lon
end
return {
description = "generates a map showing the given GPS coordinates",
usage = "!gps latitude,longitude: generates a map showing the given GPS coordinates",
patterns = {"^!gps ([^,]*)[,%s]([^,]*)$"},
run = run
}
end

View File

@ -1,24 +0,0 @@
do
function run(msg, matches)
local result = 'Hacker News Top5:\n'
local top_stories_json, code = https.request('https://hacker-news.firebaseio.com/v0/topstories.json')
if code ~=200 then return nil end
local top_stories = json:decode(top_stories_json)
for i = 1, 5 do
local story_json, code = https.request('https://hacker-news.firebaseio.com/v0/item/'..top_stories[i]..'.json')
if code ~=200 then return nil end
local story = json:decode(story_json)
result = result .. i .. '. ' .. story.title .. ' - ' .. story.url .. '\n'
end
return result
end
return {
description = "Show top 5 hacker news (ycombinator.com)",
usage = "!hackernews",
patterns = {"^!hackernews$"},
run = run
}
end

15
plugins/hallo.lua Normal file
View File

@ -0,0 +1,15 @@
function run(msg, matches)
local user_name = get_name(msg)
local receiver = get_receiver(msg)
return "Hallo " .. user_name .. "!"
end
return {
description = "Sagt hallo zu euch",
usage = "hallo",
patterns = {
"^Hallo(.*)$",
"^hallo(.*)$"
},
run = run
}

View File

@ -1,17 +0,0 @@
do
function run(msg, matches)
return "Hello, " .. matches[1]
end
return {
description = "Says hello to someone",
usage = "say hello to [name]",
patterns = {
"^say hello to (.*)$",
"^Say hello to (.*)$"
},
run = run
}
end

View File

@ -27,13 +27,13 @@ end
-- !help command -- !help command
local function telegram_help() local function telegram_help()
local text = "Plugin list: \n\n" local text = "Plugin Liste: \n\n"
-- Plugins names -- Plugins names
for name in pairs(plugins) do for name in pairs(plugins) do
text = text..name..'\n' text = text..name..'\n'
end end
text = text..'\n'..'Write "!help [plugin name]" for more info.' text = text..'\n'..'Benutze "/hilfe [Plugin Name]" für mehr Informationen'
text = text..'\n'..'Or "!help all" to show all info.' text = text..'\n'..'Oder "/hilfe all" um alles zu sehen.'
return text return text
end end
@ -47,9 +47,9 @@ local function help_all()
end end
local function run(msg, matches) local function run(msg, matches)
if matches[1] == "!help" then if matches[1] == "/hilfe" then
return telegram_help() return telegram_help()
elseif matches[1] == "!help all" then elseif matches[1] == "/hilfe all" then
return help_all() return help_all()
else else
local text = plugin_help(matches[1]) local text = plugin_help(matches[1])
@ -61,16 +61,12 @@ local function run(msg, matches)
end end
return { return {
description = "Help plugin. Get info from other plugins. ", description = "",
usage = { usage = {""},
"!help: Show list of plugins.",
"!help all: Show all commands for every plugin.",
"!help [plugin name]: Commands for that plugin."
},
patterns = { patterns = {
"^!help$", "^/hilfe$",
"^!help all", "^/hilfe all",
"^!help (.+)" "^/hilfe (.+)"
}, },
run = run run = run
} }

View File

@ -1,36 +0,0 @@
do
function imdb(movie)
local http = require("socket.http")
http.TIMEOUT = 5
local movie = movie:gsub(' ', '+')
local url = "http://www.imdbapi.com/?t=" .. movie
local response, code, headers = http.request(url)
if code ~= 200 then
return "Error: " .. code
end
if #response > 0 then
local r = json:decode(response)
r['Url'] = "http://imdb.com/title/" .. r.imdbID
local t = ""
for k, v in pairs(r) do t = t .. k .. ": " .. v .. ", " end
return t:sub(1, -3)
end
return nil
end
function run(msg, matches)
return imdb(matches[1])
end
return {
description = "Imdb plugin for telegram",
usage = "!imdb [movie]",
patterns = {"^!imdb (.+)"},
run = run
}
end

View File

@ -2,7 +2,7 @@ do
function getGoogleImage(text) function getGoogleImage(text)
local text = URL.escape(text) local text = URL.escape(text)
local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q=" local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&safe=active&q="
local res, code = http.request(api..text) local res, code = http.request(api..text)
if code ~= 200 then return nil end if code ~= 200 then return nil end
local google = json:decode(res) local google = json:decode(res)
@ -12,7 +12,7 @@ function getGoogleImage(text)
end end
local data = google.responseData local data = google.responseData
if not data or not data.results then if not data or not data.results then
return nil return nil
end end
@ -32,18 +32,18 @@ function run(msg, matches)
local url = getGoogleImage(text) local url = getGoogleImage(text)
if not url then if not url then
return "Error: Image not found" return "Kein Bild gefunden. Versuch es nochmal"
end end
print("Image URL: ", url) print("Bilder-URL: ", url)
send_photo_from_url(receiver, url) send_photo_from_url(receiver, url)
end end
return { return {
description = "Search image with Google API and sends it.", description = "Sucht Bild mit Google-API und versendet es (SafeSearch aktiv)",
usage = "!img [term]: Random search an image with Google API.", usage = "/img [Suchbegriff]",
patterns = {"^!img (.*)$"}, patterns = {"^/img (.*)$"},
run = run run = run
} }
end end

View File

@ -0,0 +1,49 @@
do
function getGoogleImage(text)
local text = URL.escape(text)
local api = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q="
local res, code = http.request(api..text)
if code ~= 200 then return nil end
local google = json:decode(res)
if google.responseStatus ~= 200 then
return nil
end
local data = google.responseData
if not data or not data.results then
return nil
end
if #data.results == 0 then
return nil
end
-- Random image from table
local i = math.random(#data.results)
return data.results[i].url
end
function run(msg, matches)
local receiver = get_receiver(msg)
local text = matches[1]
local url = getGoogleImage(text)
if not url then
return "Kein Bild gefunden. Versuch es nochmal"
end
print("Bilder-URL: ", url)
send_photo_from_url(receiver, url)
end
return {
description = "Sucht Bild mit Google-API und versendet es (SafeSearch aktiv)",
usage = "/img [Suchbegriff]",
patterns = {"^/img (.*)$"},
run = run
}
end

View File

@ -1,44 +0,0 @@
-- Invite other user to the chat group.
-- Use !invite name User_name or !invite id id_number
-- The User_name is the print_name (there are no spaces but _)
do
local function run(msg, matches)
-- User submitted a user name
if matches[1] == "name" then
user = matches[2]
user = string.gsub(user," ","_")
end
-- User submitted an id
if matches[1] == "id" then
user = matches[2]
user = 'user#id'..user
end
-- The message must come from a chat group
if msg.to.type == 'chat' then
chat = 'chat#id'..msg.to.id
else
return 'This isnt a chat group!'
end
print ("Trying to add: "..user.." to "..chat)
status = chat_add_user (chat, user, ok_cb, false)
if not status then
return "An error happened"
end
return "Added user: "..user.." to "..chat
end
return {
description = "Invite other user to the chat group",
usage = {
"!invite name [user_name]",
"!invite id [user_id]" },
patterns = {
"^!invite (name) (.*)$",
"^!invite (id) (%d+)$"
},
run = run
}
end

22
plugins/kitty.lua Normal file
View File

@ -0,0 +1,22 @@
function run(msg, matches)
if string.starts(msg.text, '/kitty') then
randomValue = math.random(4)
if randomValue == 1 then
send_photo(get_receiver(msg), "pictures/cats/cat1.jpg", ok_cb, false)
elseif randomValue == 2 then
send_photo(get_receiver(msg), "pictures/cats/cat2.jpg", ok_cb, false)
elseif randomValue == 3 then
send_photo(get_receiver(msg), "pictures/cats/cat3.jpg", ok_cb, false)
elseif randomValue == 4 then
send_photo(get_receiver(msg), "pictures/cats/cat4.jpg", ok_cb, false)
end
end
end
return {
description = "Sendet eins von 4 Katzenbilder",
usage = "/kitty",
patterns = {"^/kitty"},
run = run
}

View File

@ -1,61 +0,0 @@
-- Implement a command !loc [area] which uses
-- the static map API to get a location image
-- Not sure if this is the proper way
-- Intent: get_latlong is in time.lua, we need it here
-- loadfile "time.lua"
-- Globals
-- If you have a google api key for the geocoding/timezone api
do
local api_key = nil
local base_api = "https://maps.googleapis.com/maps/api"
function get_staticmap(area)
local api = base_api .. "/staticmap?"
-- Get a sense of scale
local lat,lng,acc,types = get_latlong(area)
local scale = types[1]
if scale=="locality" then zoom=8
elseif scale=="country" then zoom=4
else zoom = 13 end
local parameters =
"size=600x300" ..
"&zoom=" .. zoom ..
"&center=" .. URL.escape(area) ..
"&markers=color:red"..URL.escape("|"..area)
if api_key ~=nil and api_key ~= "" then
parameters = parameters .. "&key="..api_key
end
return lat, lng, api..parameters
end
function run(msg, matches)
local receiver = get_receiver(msg)
local lat,lng,url = get_staticmap(matches[1])
-- Send the actual location, is a google maps link
send_location(receiver, lat, lng, ok_cb, false)
-- Send a picture of the map, which takes scale into account
send_photo_from_url(receiver, url)
-- Return a link to the google maps stuff is now not needed anymore
return nil
end
return {
description = "Gets information about a location, maplink and overview",
usage = "!loc (location): Gets information about a location, maplink and overview",
patterns = {"^!loc (.*)$"},
run = run
}
end

32
plugins/lucky_star.lua Normal file
View File

@ -0,0 +1,32 @@
function run(msg, matches)
if string.starts(msg.text, '/kagami') or string.starts(msg.text, "/Kagami") then
send_photo(get_receiver(msg), "pictures/luckystar/kagami.jpg", ok_cb, false)
end
if string.starts(msg.text, '/konata') or string.starts(msg.text, "/Konata") then
send_photo(get_receiver(msg), "pictures/luckystar/konata.jpg", ok_cb, false)
end
if string.starts(msg.text, '/miyuki') or string.starts(msg.text, "/Miyuki") then
send_photo(get_receiver(msg), "pictures/luckystar/miyuki.jpg", ok_cb, false)
end
if string.starts(msg.text, '/tsukasa') or string.starts(msg.text, "/Tsukasa") then
send_photo(get_receiver(msg), "pictures/luckystar/tsukasa.jpg", ok_cb, false)
end
end
return {
description = "Sendet ein Bild von den Lucky Star Chars",
usage = "/kagami, /konata, /tsukasa oder /miyuki",
patterns = {"^/kagami",
"^/Kagami",
"^/konata",
"^/Konata",
"^/miyuki",
"^/Miyuki",
"^/tsukasa",
"^/Tsukasa"},
run = run
}

View File

@ -1,22 +0,0 @@
do
function run(msg, matches)
local answers = {'It is certain','It is decidedly so','Without a doubt',
'Yes definitely','You may rely on it','As I see it, yes',
'Most likely','Outlook good','Yes','Signs point to yes',
'Reply hazy try again','Ask again later',
'Better not tell you now','Cannot predict now',
'Concentrate and ask again','Don\'t count on it',
'My reply is no','My sources say no','Outlook not so good',
'Very doubtful'}
return answers[math.random(#answers)]
end
return {
description = "Magic 8Ball",
usage = "!magic8ball",
patterns = {"^!magic8ball"},
run = run
}
end

View File

@ -0,0 +1,20 @@
do
function run(msg, matches)
local answers = {'Ja','Nein','Eines Tages vielleicht'}
return answers[math.random(#answers)]
end
return {
description = "Beantwortet euch eine Frage (100% Wahrheit!)",
usage = "Magische Miesmuschel [Frage]",
patterns = {
"^Magische Miesmuschel(.*)$",
"^magische Miesmuschel(.*)$",
"^Magische miesmuschel(.*)$",
"^magische miesmuschel(.*)$"
},
run = run
}
end

View File

@ -1,6 +1,7 @@
do do
function run(msg, matches) function run(msg, matches)
local receiver = get_receiver(msg)
local file = download_to_file(matches[1]) local file = download_to_file(matches[1])
send_document(get_receiver(msg), file, ok_cb, false) send_document(get_receiver(msg), file, ok_cb, false)
end end
@ -18,9 +19,19 @@ return {
"(https?://[%w-_%.%?%.:/%+=&]+%.rar)$", "(https?://[%w-_%.%?%.:/%+=&]+%.rar)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.wmv)$", "(https?://[%w-_%.%?%.:/%+=&]+%.wmv)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.doc)$", "(https?://[%w-_%.%?%.:/%+=&]+%.doc)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.avi)$" "(https?://[%w-_%.%?%.:/%+=&]+%.tar.gz)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.dlc)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.txt)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.deb)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.webm)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.avi)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.wav)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.exe)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.rpm)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.dmg)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.apk)$"
}, },
run = run run = run
} }
end end

View File

@ -1,3 +1,4 @@
local function callback(extra, success, result) local function callback(extra, success, result)
if success then if success then
print('File downloaded to:', result) print('File downloaded to:', result)
@ -41,4 +42,4 @@ return {
'%[(audio)%]' '%[(audio)%]'
}, },
pre_process = pre_process pre_process = pre_process
} }

15
plugins/moepse.lua Normal file
View File

@ -0,0 +1,15 @@
function run(msg, matches)
return 'se'
end
return {
description = "Möpse? Meepse?",
usage = "möp oder meep",
patterns = {"^möp",
"Möp",
"meep",
"Meep"},
run = run
}

10
plugins/myid.lua Normal file
View File

@ -0,0 +1,10 @@
function run(msg, matches)
return tostring(msg.from.id) .. ' ' .. tostring(is_sudo(msg))
end
return {
description = 'Zeigt deine Telegram ID',
usage = '/myid',
patterns = {'^/myid$'},
run = run
}

11
plugins/naira_derp.lua Normal file
View File

@ -0,0 +1,11 @@
function run(msg, matches)
send_document(get_receiver(msg), "sticker/naira_derp.webp", ok_cb, false)
end
return {
description = "Naira Derp",
usage = "/nairad",
patterns = {"^/nairad",
"^/Nairad"},
run = run
}

13
plugins/nau.lua Normal file
View File

@ -0,0 +1,13 @@
function run(msg, matches)
if string.starts(msg.text, "/nau") then
send_photo(get_receiver(msg), "pictures/nau.jpg", ok_cb, false)
end
end
return {
description = "RTL Nau",
usage = "/nau",
patterns = {"^/nau"},
run = run
}

13
plugins/neorame.lua Normal file
View File

@ -0,0 +1,13 @@
function run(msg, matches)
if string.starts(msg.text, "/neorame") then
send_photo(get_receiver(msg), "pictures/neorame.jpg", ok_cb, false)
end
end
return {
description = "NeoRame is best pony!",
usage = "/neorame",
patterns = {"^/neorame"},
run = run
}

18
plugins/niissan.lua Normal file
View File

@ -0,0 +1,18 @@
function run(msg, matches)
if string.starts(msg.text, 'nii-san') or string.starts(msg.text, 'Nii-san') or string.starts(msg.text, 'Nissan') or string.starts(msg.text, 'nissan') then
send_photo(get_receiver(msg), "pictures/Nii-san.jpg", ok_cb, false)
end
end
return {
description = "Nii-san <3",
usage = "nii-san, Nii-san, nissan oder Nissan",
patterns = {"^nii-san",
"^Nii-san",
"^nissan",
"^Nissan"},
run = run
}

15
plugins/nope.avi.lua Normal file
View File

@ -0,0 +1,15 @@
function run(msg, matches)
if matches[1] == "nope.avi" then
return 'https://www.youtube.com/watch?v=gvdf5n-zI14'
end
end
return {
description = 'Sendet ein YouTube Video namens "nope.avi"',
usage = "nope.avi",
patterns = {"^nope.avi"},
run = run
}

16
plugins/nyu.lua Normal file
View File

@ -0,0 +1,16 @@
function run(msg, matches)
if string.starts(msg.text, 'nyu') or string.starts(msg.text, 'Nyu') then
send_photo(get_receiver(msg), "pictures/nyu.jpg", ok_cb, false)
end
end
return {
description = "Nyu?",
usage = "nyu",
patterns = {"^nyu",
"^Nyu"},
run = run
}

View File

@ -1,28 +0,0 @@
do
local socket = require("socket")
function cron()
-- Use yours desired web and id
local addr = "www.google.com"
local dest = "user#id"..our_id
-- Checks a TCP connexion
local connexion = socket.connect(addr, 80)
if not connexion then
local text = "ALERT: "..addr.." is offline"
print (text)
send_msg(dest, text, ok_cb, false)
else
connexion:close()
end
end
return {
description = "If domain is offline, send msg to peer",
usage = "",
patterns = {},
run = nil,
cron = cron
}
end

View File

@ -51,7 +51,7 @@ end
local function enable_plugin( filename ) local function enable_plugin( filename )
-- Check if plugin is enabled -- Check if plugin is enabled
if plugin_enabled(filename) then if plugin_enabled(filename) then
return 'Plugin '..filename..' is enabled' return 'Plugin '..filename..' ist aktiviert!'
end end
-- Checks if plugin exists -- Checks if plugin exists
if plugin_exists(filename) then if plugin_exists(filename) then
@ -61,19 +61,19 @@ local function enable_plugin( filename )
-- Reload the plugins -- Reload the plugins
return reload_plugins( ) return reload_plugins( )
else else
return 'Plugin '..filename..' does not exists' return 'Das Plugin '..filename..' exestiert nicht!'
end end
end end
local function disable_plugin( name, chat ) local function disable_plugin( name, chat )
-- Check if plugins exists -- Check if plugins exists
if not plugin_exists(name) then if not plugin_exists(name) then
return 'Plugin '..name..' does not exists' return 'Das Plugin '..name..' exestiert nicht!'
end end
local k = plugin_enabled(name) local k = plugin_enabled(name)
-- Check if plugin is enabled -- Check if plugin is enabled
if not k then if not k then
return 'Plugin '..name..' not enabled' return 'Das Plugin '..name..' ist nicht aktiviert!'
end end
-- Disable and reload -- Disable and reload
table.remove(_config.enabled_plugins, k) table.remove(_config.enabled_plugins, k)
@ -83,7 +83,7 @@ end
local function disable_plugin_on_chat(receiver, plugin) local function disable_plugin_on_chat(receiver, plugin)
if not plugin_exists(plugin) then if not plugin_exists(plugin) then
return "Plugin doesn't exists" return "Das Plugin exestiert nicht!"
end end
if not _config.disabled_plugin_on_chat then if not _config.disabled_plugin_on_chat then
@ -97,7 +97,7 @@ local function disable_plugin_on_chat(receiver, plugin)
_config.disabled_plugin_on_chat[receiver][plugin] = true _config.disabled_plugin_on_chat[receiver][plugin] = true
save_config() save_config()
return 'Plugin '..plugin..' disabled on this chat' return 'Das Plugin '..plugin..' ist hier nun deaktiviert!'
end end
local function reenable_plugin_on_chat(receiver, plugin) local function reenable_plugin_on_chat(receiver, plugin)
@ -110,16 +110,16 @@ local function reenable_plugin_on_chat(receiver, plugin)
end end
if not _config.disabled_plugin_on_chat[receiver][plugin] then if not _config.disabled_plugin_on_chat[receiver][plugin] then
return 'This plugin is not disabled' return 'Dieses Plugin ist nicht deaktiviert!'
end end
_config.disabled_plugin_on_chat[receiver][plugin] = false _config.disabled_plugin_on_chat[receiver][plugin] = false
return 'Plugin '..plugin..' is enabled again' return 'Das Plugin '..plugin..' ist wieder aktiviert!'
end end
local function run(msg, matches) local function run(msg, matches)
-- Show the available plugins -- Show the available plugins
if matches[1] == '!plugins' then if matches[1] == '/plugins' then
return list_plugins() return list_plugins()
end end
@ -158,20 +158,15 @@ local function run(msg, matches)
end end
return { return {
description = "Plugin to manage other plugins. Enable, disable or reload.", description = "",
usage = { usage = {""},
"!plugins: list all plugins.",
"!plugins enable [plugin]: enable plugin.",
"!plugins disable [plugin]: disable plugin.",
"!plugins disable [plugin] chat: disable plugin only this chat.",
"!plugins reload: reloads all plugins." },
patterns = { patterns = {
"^!plugins$", "^/plugins$",
"^!plugins? (enable) ([%w_%.%-]+)$", "^/plugins? (enable) ([%w_%.%-]+)$",
"^!plugins? (disable) ([%w_%.%-]+)$", "^/plugins? (disable) ([%w_%.%-]+)$",
"^!plugins? (disable) ([%w_%.%-]+) (chat)", "^/plugins? (disable) ([%w_%.%-]+) (chat)",
"^!plugins? (enable) ([%w_%.%-]+) (chat)", "^/plugins? (enable) ([%w_%.%-]+) (chat)",
"^!plugins? (reload)$" }, "^/plugins? (reload)$" },
run = run, run = run,
privileged = true privileged = true
} }

View File

@ -1,72 +0,0 @@
local quotes_file = './data/quotes.lua'
local quotes_table
function read_quotes_file()
local f = io.open(quotes_file, "r+")
if f == nil then
print ('Created a new quotes file on '..quotes_file)
serialize_to_file({}, quotes_file)
else
print ('Quotes loaded: '..quotes_file)
f:close()
end
return loadfile (quotes_file)()
end
function save_quote(msg)
local to_id = tostring(msg.to.id)
if msg.text:sub(11):isempty() then
return "Usage: !addquote quote"
end
if quotes_table == nil then
quotes_table = {}
end
if quotes_table[to_id] == nil then
print ('New quote key to_id: '..to_id)
quotes_table[to_id] = {}
end
local quotes = quotes_table[to_id]
quotes[#quotes+1] = msg.text:sub(11)
serialize_to_file(quotes_table, quotes_file)
return "done!"
end
function get_quote(msg)
local to_id = tostring(msg.to.id)
local quotes_phrases
quotes_table = read_quotes_file()
quotes_phrases = quotes_table[to_id]
return quotes_phrases[math.random(1,#quotes_phrases)]
end
function run(msg, matches)
if string.match(msg.text, "!quote$") then
return get_quote(msg)
elseif string.match(msg.text, "!addquote (.+)$") then
quotes_table = read_quotes_file()
return save_quote(msg)
end
end
return {
description = "Save quote",
description = "Quote plugin, you can create and retrieves random quotes",
usage = {
"!addquote [msg]",
"!quote",
},
patterns = {
"^!addquote (.+)$",
"^!quote$",
},
run = run
}

View File

@ -1,65 +0,0 @@
do
function getDulcinea( text )
-- Powered by https://github.com/javierhonduco/dulcinea
local api = "http://dulcinea.herokuapp.com/api/?query="
local query_url = api..text
local b, code = http.request(query_url)
if code ~= 200 then
return "Error: HTTP Connexion"
end
dulcinea = json:decode(b)
if dulcinea.status == "error" then
return "Error: " .. dulcinea.message
end
while dulcinea.type == "multiple" do
text = dulcinea.response[1].id
b = http.request(api..text)
dulcinea = json:decode(b)
end
local text = ""
local responses = #dulcinea.response
if responses == 0 then
return "Error: 404 word not found"
end
if (responses > 5) then
responses = 5
end
for i = 1, responses, 1 do
text = text .. dulcinea.response[i].word .. "\n"
local meanings = #dulcinea.response[i].meanings
if (meanings > 5) then
meanings = 5
end
for j = 1, meanings, 1 do
local meaning = dulcinea.response[i].meanings[j].meaning
text = text .. meaning .. "\n\n"
end
end
return text
end
function run(msg, matches)
return getDulcinea(matches[1])
end
return {
description = "Spanish dictionary",
usage = "!rae [word]: Search that word in Spanish dictionary.",
patterns = {"^!rae (.*)$"},
run = run
}
end

19
plugins/rich_bitch.lua Normal file
View File

@ -0,0 +1,19 @@
function run(msg, matches)
if matches[1] == "rich bitch" then
return 'Akamaru ist nicht reich!'
end
end
return {
description = "Sagt euch dass Akamaru nicht reich ist",
usage = "rich bitch",
patterns = {"^Rich Bitch",
"^rich bitch",
"^rich Bitch",
"^Rich bitch",
"^RICH BITCH"},
run = run
}

50
plugins/sakurasou.lua Normal file
View File

@ -0,0 +1,50 @@
function run(msg, matches)
if string.starts(msg.text, '/shiina') or string.starts(msg.text, "/Shiina") then
send_photo(get_receiver(msg), "pictures/sakurasou/shiina.jpg", ok_cb, false)
end
if string.starts(msg.text, '/chihiro') or string.starts(msg.text, "/Chihiro") then
send_photo(get_receiver(msg), "pictures/sakurasou/chihiro.jpg", ok_cb, false)
end
if string.starts(msg.text, '/jin') or string.starts(msg.text, "/Jin") then
send_photo(get_receiver(msg), "pictures/sakurasou/jin.jpg", ok_cb, false)
end
if string.starts(msg.text, '/misaki') or string.starts(msg.text, "/Misaki") then
send_photo(get_receiver(msg), "pictures/sakurasou/misaki.jpg", ok_cb, false)
end
if string.starts(msg.text, '/nanami') or string.starts(msg.text, "/Nanami") then
send_photo(get_receiver(msg), "pictures/sakurasou/nanami.jpg", ok_cb, false)
end
if string.starts(msg.text, '/ryuunosuke') or string.starts(msg.text, "/Ryuunosuke") then
send_photo(get_receiver(msg), "pictures/sakurasou/ryuunosuke.jpg", ok_cb, false)
end
if string.starts(msg.text, '/sorata') or string.starts(msg.text, "/Sorata") then
send_photo(get_receiver(msg), "pictures/sakurasou/sorata.jpg", ok_cb, false)
end
end
return {
description = "",
usage = "",
patterns = {"^/shiina",
"^/Shiina",
"^/chihiro",
"^/Chihiro",
"^/jin",
"^/Jin",
"^/misaki",
"^/Misaki",
"^/nanami",
"^/Nanami",
"^/ryuunosuke",
"^/Ryuunosuke",
"^/sorata",
"^/Sorata"},
run = run
}

View File

@ -29,7 +29,7 @@ local function searchYoutubeVideo(text)
print("HTTP Error") print("HTTP Error")
return nil return nil
elseif not data.feed.entry then elseif not data.feed.entry then
return "YouTube video not found!" return "Kein YouTube Video gefunden!"
end end
return data.feed.entry[1].link[1].href return data.feed.entry[1].link[1].href
end end
@ -43,10 +43,10 @@ local function run(msg, matches)
end end
return { return {
description = "Search video on youtube and send it.", description = "Sucht ein Video auf YouTube und sendet es",
usage = "!youtube [term]: Search for a youtube video and send it.", usage = "/youtube [Begriff]",
patterns = { patterns = {
"^!youtube (.*)" "^/youtube (.*)"
}, },
run = run run = run
} }

69
plugins/senran_kagura.lua Normal file
View File

@ -0,0 +1,69 @@
function run(msg, matches)
if string.starts(msg.text, '/asuka') or string.starts(msg.text, "/Asuka") then
send_photo(get_receiver(msg), "pictures/senrankagura/hanzouacademy/asuka.jpg", ok_cb, false)
end
if string.starts(msg.text, '/hibari') or string.starts(msg.text, "/Hibari") then
send_photo(get_receiver(msg), "pictures/senrankagura/hanzouacademy/hibari.jpg", ok_cb, false)
end
if string.starts(msg.text, '/ikaruga') or string.starts(msg.text, "/Ikaruga") then
send_photo(get_receiver(msg), "pictures/senrankagura/hanzouacademy/ikaruga.jpg", ok_cb, false)
end
if string.starts(msg.text, '/katsuragi') or string.starts(msg.text, "/Katsuragi") then
send_photo(get_receiver(msg), "pictures/senrankagura/hanzouacademy/katsuragi.jpg", ok_cb, false)
end
if string.starts(msg.text, '/yagyuu') or string.starts(msg.text, "/Yagyuu") then
send_photo(get_receiver(msg), "pictures/senrankagura/hanzouacademy/yagyuu.jpg", ok_cb, false)
end
if string.starts(msg.text, '/haruka') or string.starts(msg.text, "/Haruka") then
send_photo(get_receiver(msg), "pictures/senrankagura/hebijoacademy/haruka.jpg", ok_cb, false)
end
if string.starts(msg.text, '/hikage') or string.starts(msg.text, "/Hikage") then
send_photo(get_receiver(msg), "pictures/senrankagura/hebijoacademy/hikage.jpg", ok_cb, false)
end
if string.starts(msg.text, '/homura') or string.starts(msg.text, "/Homura") then
send_photo(get_receiver(msg), "pictures/senrankagura/hebijoacademy/homura.jpg", ok_cb, false)
end
if string.starts(msg.text, '/mirai') or string.starts(msg.text, "/Mirai") then
send_photo(get_receiver(msg), "pictures/senrankagura/hebijoacademy/mirai.jpg", ok_cb, false)
end
if string.starts(msg.text, '/yomi') or string.starts(msg.text, "/Yomi") then
send_photo(get_receiver(msg), "pictures/senrankagura/hebijoacademy/yomi.jpg", ok_cb, false)
end
end
return {
description = "",
usage = "",
patterns = {"^/asuka",
"^/Asuka",
"^/hibari",
"^/Hibari",
"^/ikaruga",
"^/Ikaruga",
"^/katsuragi",
"^/Katsuragi",
"^/yagyuu",
"^/Yagyuu",
"^/haruka",
"^/Haruka",
"^/hikage",
"^/Hikage",
"^/homura",
"^/Homura",
"^/mirai",
"^/Mirai",
"^/yomi",
"^/Yomi"},
run = run
}

View File

@ -1,31 +0,0 @@
local _file_values = './data/values.lua'
function save_value(chat, text )
var_name, var_value = string.match(text, "!set (%a+) (.+)")
if (var_name == nil or var_value == nil) then
return "Usage: !set var_name value"
end
if _values[chat] == nil then
_values[chat] = {}
end
_values[chat][var_name] = var_value
-- Save values to file
serialize_to_file(_values, _file_values)
return "Saved "..var_name.." = "..var_value
end
function run(msg, matches)
local chat_id = tostring(msg.to.id)
local text = save_value(chat_id, msg.text)
return text
end
return {
description = "Plugin for saving values. get.lua plugin is necesary to retrieve them.",
usage = "!set [value_name] [data]: Saves the data with the value_name name.",
patterns = {"^!set (%a+) (.+)$"},
run = run
}

38
plugins/sh.lua Normal file
View File

@ -0,0 +1,38 @@
function run_sh(msg)
name = get_name(msg)
text = ''
bash = msg.text:sub(4,-1)
text = run_bash(bash)
return text
end
function run_bash(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
function run(msg, matches)
local receiver = get_receiver(msg)
if string.starts(msg.text, '/sh') then
text = run_sh(msg)
send_msg(receiver, text, ok_cb, false)
return
end
if string.starts(msg.text, '/uptime') then
text = run_bash('uptime')
send_msg(receiver, text, ok_cb, false)
return
end
end
return {
description = "Führt Befehle in der Konsole aus",
usage = "",
patterns = {"^/uptime", "^/sh (.*)$"},
run = run,
privileged = true
}

View File

@ -104,10 +104,10 @@ end
_stats = read_file_stats() _stats = read_file_stats()
return { return {
description = "Plugin to update user stats.", description = "",
usage = "!stats: Returns a list of Username [telegram_id]: msg_num", usage = "",
patterns = { patterns = {
"^!(stats)", "^/(stats)",
".*" ".*"
}, },
run = run, run = run,

View File

@ -1,3 +1,4 @@
-- See https://wiki.teamfortress.com/wiki/User:RJackson/StorefrontAPI -- See https://wiki.teamfortress.com/wiki/User:RJackson/StorefrontAPI
do do
@ -28,8 +29,8 @@ end
function send_steam_data(data, receiver) function send_steam_data(data, receiver)
local description = string.sub(unescape(data.about_the_game:gsub("%b<>", "")), 1, DESC_LENTH) .. '...' local description = string.sub(unescape(data.about_the_game:gsub("%b<>", "")), 1, DESC_LENTH) .. '...'
local title = data.name local title = data.name
local price = "$"..(data.price_overview.initial/100) local price = ""..(data.price_overview.initial/100)
local sale_price = "$"..(data.price_overview.final/100) local sale_price = ""..(data.price_overview.final/100)
local percent_savings = data.price_overview.discount_percent local percent_savings = data.price_overview.discount_percent
local price_display = price local price_display = price

21
plugins/stille.lua Normal file
View File

@ -0,0 +1,21 @@
do
function run(msg, matches)
local answers = {'Ja, es ist sehr ruhig hier','Wenn es dir zu still ist, kannst du gerne mit mir reden','*SCHREI*',
'Dann mach doch etwas dagegen!','Möpse?','Vermutlich schlafen alle',
'Stört dich die Stille?','Nein, es ist nicht still','Nyu?',
'Besser als Spam','Stille ist schön',
'Mein Name ist Mikubot','Spiel doch etwas http://curvefever.com/',
'Stille sagt manchmal mehr als tausend Worte','Stille und Nacht sind untrennbar verwoben. Die Nacht ist die Stille unter den Sternen.'}
return answers[math.random(#answers)]
end
return {
description = "Es ist so still hier",
usage = "stille",
patterns = {"^Stille",
"^stille"},
run = run
}
end

View File

@ -1,100 +0,0 @@
-- Implement a command !time [area] which uses
-- 2 Google APIs to get the desired result:
-- 1. Geocoding to get from area to a lat/long pair
-- 2. Timezone to get the local time in that lat/long location
-- Globals
-- If you have a google api key for the geocoding/timezone api
api_key = nil
base_api = "https://maps.googleapis.com/maps/api"
dateFormat = "%A %d %B - %H:%M:%S"
-- Need the utc time for the google api
function utctime()
return os.time(os.date("!*t"))
end
-- Use the geocoding api to get the lattitude and longitude with accuracy specifier
-- CHECKME: this seems to work without a key??
function get_latlong(area)
local api = base_api .. "/geocode/json?"
local parameters = "address=".. (URL.escape(area) or "")
if api_key ~= nil then
parameters = parameters .. "&key="..api_key
end
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Get the data
lat = data.results[1].geometry.location.lat
lng = data.results[1].geometry.location.lng
acc = data.results[1].geometry.location_type
types= data.results[1].types
return lat,lng,acc,types
end
end
-- Use timezone api to get the time in the lat,
-- Note: this needs an API key
function get_time(lat,lng)
local api = base_api .. "/timezone/json?"
-- Get a timestamp (server time is relevant here)
local timestamp = utctime()
local parameters = "location=" ..
URL.escape(lat) .. "," ..
URL.escape(lng) ..
"&timestamp="..URL.escape(timestamp)
if api_key ~=nil then
parameters = parameters .. "&key="..api_key
end
local res,code = https.request(api..parameters)
if code ~= 200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Construct what we want
-- The local time in the location is:
-- timestamp + rawOffset + dstOffset
local localTime = timestamp + data.rawOffset + data.dstOffset
return localTime, data.timeZoneId
end
return localTime
end
function getformattedLocalTime(area)
if area == nil then
return "The time in nowhere is never"
end
lat,lng,acc = get_latlong(area)
if lat == nil and lng == nil then
return 'It seems that in "'..area..'" they do not have a concept of time.'
end
local localTime, timeZoneId = get_time(lat,lng)
return "The local time in "..timeZoneId.." is: ".. os.date(dateFormat,localTime)
end
function run(msg, matches)
return getformattedLocalTime(matches[1])
end
return {
description = "Displays the local time in an area",
usage = "!time [area]: Displays the local time in that area",
patterns = {"^!time (.*)$"},
run = run
}

View File

@ -1,81 +0,0 @@
--[[
-- Translate text using Google Translate.
-- http://translate.google.com/translate_a/t?client=z&ie=UTF-8&oe=UTF-8&hl=en&tl=en&text=hello
--]]
do
function translate(source_lang, target_lang, text)
local path = "http://translate.google.com/translate_a/t"
-- URL query parameters
local params = {
client = "z", -- JSON
ie = "UTF-8",
oe = "UTF-8",
hl = "en",
tl = target_lang or "en",
sl = source_lang or "",
text = URL.escape(text)
}
local query = format_http_params(params, true)
local url = path..query
local res, code = https.request(url)
-- Return nil if error
if code > 200 then return nil end
local trans = json:decode(res)
local sentences = ""
-- Join multiple sencentes
for k,sentence in pairs(trans.sentences) do
sentences = sentences..sentence.trans..'\n'
end
return sentences
end
function run(msg, matches)
-- Third pattern
if #matches == 1 then
print("First")
local text = matches[1]
return translate(nil, nil, text)
end
-- Second pattern
if #matches == 2 then
print("Second")
local target = matches[1]
local text = matches[2]
return translate(nil, target, text)
end
-- Frist pattern
if #matches == 3 then
print("Third")
local source = matches[1]
local target = matches[2]
local text = matches[3]
return translate(source, target, text)
end
end
return {
description = "Translate some text",
usage = {
"!translate text. Translate to english the text.",
"!translate target_lang text.",
"!translate source,target text",
},
patterns = {
"^!translate ([%w]+),([%a]+) (.+)",
"^!translate ([%w]+) (.+)",
"^!translate (.+)",
},
run = run
}
end

View File

@ -1,74 +0,0 @@
local OAuth = require "OAuth"
local consumer_key = ""
local consumer_secret = ""
local access_token = ""
local access_token_secret = ""
local client = OAuth.new(consumer_key, consumer_secret, {
RequestToken = "https://api.twitter.com/oauth/request_token",
AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"},
AccessToken = "https://api.twitter.com/oauth/access_token"
}, {
OAuthToken = access_token,
OAuthTokenSecret = access_token_secret
})
function run(msg, matches)
if consumer_key:isempty() then
return "Twitter Consumer Key is empty, write it in plugins/twitter.lua"
end
if consumer_secret:isempty() then
return "Twitter Consumer Secret is empty, write it in plugins/twitter.lua"
end
if access_token:isempty() then
return "Twitter Access Token is empty, write it in plugins/twitter.lua"
end
if access_token_secret:isempty() then
return "Twitter Access Token Secret is empty, write it in plugins/twitter.lua"
end
local twitter_url = "https://api.twitter.com/1.1/statuses/show/" .. matches[1] .. ".json"
local response_code, response_headers, response_status_line, response_body = client:PerformRequest("GET", twitter_url)
local response = json:decode(response_body)
local header = "Tweet from " .. response.user.name .. " (@" .. response.user.screen_name .. ")\n"
local text = response.text
-- replace short URLs
if response.entities.url then
for k, v in pairs(response.entities.urls) do
local short = v.url
local long = v.expanded_url
text = text:gsub(short, long)
end
end
-- remove images
local images = {}
if response.extended_entities and response.extended_entities.media then
for k, v in pairs(response.extended_entities.media) do
local url = v.url
local pic = v.media_url
text = text:gsub(url, "")
table.insert(images, pic)
end
end
-- send the parts
local receiver = get_receiver(msg)
send_msg(receiver, header .. "\n" .. text, ok_cb, false)
send_photos_from_url(receiver, images)
return nil
end
return {
description = "When user sends twitter URL, send text and images to origin. Requieres OAuth Key.",
usage = "",
patterns = {
"https://twitter.com/[^/]+/status/([0-9]+)"
},
run = run
}

View File

@ -1,54 +0,0 @@
do
local OAuth = require "OAuth"
local consumer_key = ""
local consumer_secret = ""
local access_token = ""
local access_token_secret = ""
local client = OAuth.new(consumer_key, consumer_secret, {
RequestToken = "https://api.twitter.com/oauth/request_token",
AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"},
AccessToken = "https://api.twitter.com/oauth/access_token"
}, {
OAuthToken = access_token,
OAuthTokenSecret = access_token_secret
})
function run(msg, matches)
if consumer_key:isempty() then
return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua"
end
if consumer_secret:isempty() then
return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua"
end
if access_token:isempty() then
return "Twitter Access Token is empty, write it in plugins/twitter_send.lua"
end
if access_token_secret:isempty() then
return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua"
end
if not is_sudo(msg) then
return "You aren't allowed to send tweets"
end
local response_code, response_headers, response_status_line, response_body =
client:PerformRequest("POST", "https://api.twitter.com/1.1/statuses/update.json", {
status = matches[1]
})
if response_code ~= 200 then
return "Error: "..response_code
end
return "Tweet sended"
end
return {
description = "Sends a tweet",
usage = "!tw [text]: Sends the Tweet with the configured accout.",
patterns = {"^!tw (.+)"},
run = run
}
end

47
plugins/url_title.lua Normal file
View File

@ -0,0 +1,47 @@
do
function getTitle(page)
local s = page
-- Remove optional spaces from the tags.
s = string.gsub(s, "\n", " ")
s = string.gsub(s, " *< *", "<")
s = string.gsub(s, " *> *", ">")
-- Put all the tags in lowercase.
s = string.gsub(s, "(<[^ >]+)", string.lower)
local i, f, t = string.find(s, "<title>(.+)</title>")
return t or ""
end
function string.ends(str, fin)
return fin=='' or string.sub(str,-string.len(fin)) == fin
end
function run(msg, matches)
local url = matches[1]
if string.ends(url, ".jpg") or string.ends(url, ".gif") or string.ends(url, ".png") then
return
end
local result = http.request(url)
local title = getTitle(result)
-- We don't want 301 (and one Extrawurst for Google), 302, 404 and empty titles
if title == "301 Moved Permanently" or title == "" or title == "404 Not Found" or title == "302 Found" or title == "Moved Permanently" then
print('Invalide, da "'..title..'"')
else
return title
end
end
return {
description = "Postet URL-Titel",
usage = "",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
end

View File

@ -1,16 +1,14 @@
do do
function run(msg, matches) function run(msg, matches)
return 'Telegram Bot '.. VERSION .. [[ return 'Mikubot '.. VERSION ..' by Akamaru'
Checkout http://git.io/6jdjGg
GNU GPL v2 license.]]
end end
return { return {
description = "Shows bot version", description = "Zeigt die Bot Version",
usage = "!version: Shows bot version", usage = "/version",
patterns = { patterns = {
"^!version$" "^/version$"
}, },
run = run run = run
} }

View File

@ -1,88 +0,0 @@
do
local _file_votes = './data/votes.lua'
function read_file_votes ()
local f = io.open(_file_votes, "r+")
if f == nil then
print ('Created voting file '.._file_votes)
serialize_to_file({}, _file_votes)
else
print ('Values loaded: '.._file_votes)
f:close()
end
return loadfile (_file_votes)()
end
function clear_votes (chat)
local _votes = read_file_votes ()
_votes [chat] = {}
serialize_to_file(_votes, _file_votes)
end
function votes_result (chat)
local _votes = read_file_votes ()
local results = {}
local result_string = ""
if _votes [chat] == nil then
_votes[chat] = {}
end
for user,vote in pairs (_votes[chat]) do
if (results [vote] == nil) then
results [vote] = user
else
results [vote] = results [vote] .. ", " .. user
end
end
for vote,users in pairs (results) do
result_string = result_string .. vote .. " : " .. users .. "\n"
end
return result_string
end
function save_vote(chat, user, vote)
local _votes = read_file_votes ()
if _votes[chat] == nil then
_votes[chat] = {}
end
_votes[chat][user] = vote
serialize_to_file(_votes, _file_votes)
end
function run(msg, matches)
if (matches[1] == "ing") then
if (matches [2] == "reset") then
clear_votes (tostring(msg.to.id))
return "Voting statistics reset.."
elseif (matches [2] == "stats") then
local votes_result = votes_result (tostring(msg.to.id))
if (votes_result == "") then
votes_result = "[No votes registered]\n"
end
return "Voting statistics :\n" .. votes_result
end
else
save_vote(tostring(msg.to.id), msg.from.print_name, tostring(tonumber(matches[2])))
return "Vote registered : " .. msg.from.print_name .. " " .. tostring(tonumber(matches [2]))
end
end
return {
description = "Plugin for voting in groups.",
usage = {
"!voting reset: Reset all the votes.",
"!vote [number]: Cast the vote.",
"!voting stats: Shows the statistics of voting."
},
patterns = {
"^!vot(ing) (reset)",
"^!vot(ing) (stats)",
"^!vot(e) ([0-9]+)$"
},
run = run
}
end

13
plugins/wd.lua Normal file
View File

@ -0,0 +1,13 @@
function run(msg, matches)
local user_name = get_name(msg)
return "" .. user_name .. " ist wieder da"
end
return {
description = "Sagt dass ihr wieder da seid",
usage = "/wd",
patterns = {
"^/wd(.*)$"
},
run = run
}

View File

@ -1,45 +0,0 @@
do
local BASE_URL = "http://api.openweathermap.org/data/2.5"
function get_weather(location)
print("Finding weather in ", location)
local b, c, h = http.request(BASE_URL.."/weather?q=" .. location .. "&units=metric")
local weather = json:decode(b)
print("Weather returns", weather)
local city = weather.name
local country = weather.sys.country
local temp = 'The temperature in ' .. city .. ' (' .. country .. ')'
temp = temp .. ' is ' .. weather.main.temp .. '°C'
conditions = 'Current conditions are: ' .. weather.weather[1].description
if weather.weather[1].main == 'Clear' then
conditions = conditions .. ''
elseif weather.weather[1].main == 'Clouds' then
conditions = conditions .. ' ☁☁'
elseif weather.weather[1].main == 'Rain' then
conditions = conditions .. ''
elseif weather.weather[1].main == 'Thunderstorm' then
conditions = conditions .. ' ☔☔☔☔'
end
return temp .. '\n' .. conditions
end
function run(msg, matches)
if string.len(matches[1]) > 2 then
city = matches[1]
else
city = "Madrid,ES"
end
return get_weather(city)
end
return {
description = "weather in that city (Madrid is default)",
usage = "!weather (city)",
patterns = {"^!weather(.*)$"},
run = run
}
end

Some files were not shown because too many files have changed in this diff Show More