forked from topkecleon/otouto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added spotify plugin (thanks to @TiagoDanin)
fixed kickass plugin (required HTTPS) included console.lua (for those who may use it) included link to otouto update channel in about.lua
- Loading branch information
1 parent
ab16426
commit c7ba76e
Showing
8 changed files
with
134 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
config.lua | ||
loc/weeb.lua | ||
console.lua | ||
*.json | ||
plugins/owm.lua | ||
plugins/liberblock.lua | ||
plugins/dgmp.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
JSON = require('dkjson') | ||
URL = require('socket.url') | ||
HTTP = require('socket.http') | ||
HTTPS= require('ssl.https') | ||
|
||
require('utilities') | ||
config = require('config') | ||
require('bindings') | ||
|
||
data = load_data('moderation.json') | ||
|
||
print('Fetching bot data...') | ||
bot = get_me().result | ||
if not bot then | ||
error('Failure fetching bot information.') | ||
end | ||
for k,v in pairs(bot) do | ||
print('',k,v) | ||
end | ||
|
||
print('Loading plugins...') | ||
plugins = {} | ||
for i,v in ipairs(config.plugins) do | ||
local p = dofile('plugins/'..v) | ||
table.insert(plugins, p) | ||
end | ||
|
||
clear = function() | ||
for i = 1, 100 do | ||
print('\n') | ||
end | ||
end | ||
|
||
print('You are now in the otouto console!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
local PLUGIN = {} | ||
|
||
PLUGIN.doc = [[ | ||
/weather <location> | ||
Returns the current temperature and weather conditions for a specified location. | ||
Non-city locations are accepted; "/weather Buckingham Palace" will return the weather for Westminster. | ||
]] | ||
|
||
PLUGIN.triggers = { | ||
'^/weather' | ||
} | ||
|
||
function PLUGIN.action(msg) | ||
|
||
local input = get_input(msg.text) | ||
if not input then | ||
return send_msg(msg, PLUGIN.doc) | ||
end | ||
|
||
coords = get_coords(input) | ||
if not coords then | ||
return send_msg(msg, config.locale.errors.results) | ||
end | ||
|
||
local url = 'http://api.openweathermap.org/data/2.5/weather?lat=' .. coords.lat .. '&lon=' .. coords.lon | ||
local jstr, res = HTTP.request(url) | ||
if res ~= 200 then | ||
return send_msg(msg, config.locale.errors.connection) | ||
end | ||
local jdat = JSON.decode(jstr) | ||
|
||
local celsius = jdat.main.temp - 273.15 | ||
local fahrenheit = tonumber(string.format("%.2f", celsius * (9/5) + 32)) | ||
local message = celsius .. '°C | ' .. fahrenheit .. '°F, ' .. jdat.weather[1].description .. '.' | ||
|
||
send_msg(msg, message) | ||
|
||
end | ||
|
||
return PLUGIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- Spotify Plugin for bot based on otouto | ||
-- ByTiagoDanin - Telegram.me/tiagodanin | ||
local PLUGIN = {} | ||
|
||
PLUGIN.doc = [[ | ||
/spotify <music> | ||
Track Spotify music. | ||
]] | ||
|
||
PLUGIN.triggers = { | ||
'^/spoti$', | ||
'^/spotify' | ||
} | ||
|
||
function PLUGIN.action(msg) | ||
|
||
local input = get_input(msg.text) | ||
if not input then | ||
return send_msg(msg, PLUGIN.doc) | ||
end | ||
--URL API | ||
local BASE_URL = "https://api.spotify.com/v1/search" | ||
local URLP = "?q=".. (URL.escape(input) or "").."&type=track&limit=5" -- Limit 5 | ||
-- Decode json | ||
local decj, tim = HTTPS.request(BASE_URL..URLP) | ||
if tim ~=200 then return nil end | ||
-- Table | ||
local spotify = JSON.decode(decj) | ||
local tables = {} | ||
for pri,result in ipairs(spotify.tracks.items) do | ||
table.insert(tables, { | ||
spotify.tracks.total, | ||
result.name .. ' - ' .. result.artists[1].name, | ||
result.external_urls.spotify | ||
}) | ||
end | ||
-- Print Tables | ||
local gets = "" | ||
for pri,cont in ipairs(tables) do | ||
gets=gets.."▶️ "..cont[2].."\n"..cont[3].."\n" | ||
end | ||
-- ERRO 404 | ||
local text_end = gets -- Text END | ||
if gets == "" then | ||
text_end = "Not found music" | ||
end | ||
-- Send MSG | ||
send_msg(msg, text_end) | ||
|
||
end | ||
|
||
return PLUGIN |