Skip to content

Instantly share code, notes, and snippets.

@Brawl345
Last active July 31, 2016 18:09
Show Gist options
  • Save Brawl345/e671b60e24243da81934 to your computer and use it in GitHub Desktop.
Save Brawl345/e671b60e24243da81934 to your computer and use it in GitHub Desktop.
Things
if not allowed then
print('User '..msg.from.id..' not whitelisted')
if msg.to.type == 'chat' then
allowed = is_chat_whitelisted(msg.to.id)
if not allowed then
print ('Chat '..msg.to.id..' not whitelisted')
else
print ('Chat '..msg.to.id..' whitelisted :)')
end
else
local user_name = get_name(msg) -- optional, if you want to use the users name
local receiver = get_receiver(msg)
send_msg(receiver, "Hey "..user_name..", this is my bot (maybe include @username) and can only be used, when you were regisered by me." , ok_cb, false)
end
else
print('User '..msg.from.id..' allowed :)')
end
SEK Sweden kronor
ATS Austria shilling
AUD Australian dollar
BEF Belgien franc
BRL Brazilien real
CAD Canada dollar
CHF Switzerland francs
CNY China yuan renminbi
CYP Cyprus pound
CZK Czech Republic koruna
DEM Germany mark
DKK Denmark krone
EEK Estonian kroon
ESP Spain pesetas
EUR Euroland euro
FIM Finland marka
FRF France franc
GBP Great Britain pound
GRD Greece drachmer
HKD Hong Kong dollar
HUF Hungary forint
IDR Indonesia rupiah
IEP Ireland pund
INR India rupee
ISK Iceland kronor
ITL Italy lire
JPY Japan yen
KRW South Korea won
KWD Kuwait dinar
LTL Lithuanialitas
LVL Latvia lat
MAD Morocko dirham
MXN Mexico nuevo peso
MYR Malaysia ringgit
NLG Dutchland guilder
NOK Norway krone
NZD New Zealand dollar
PLN Poland zloty
PTE Portugal escudo
RUB Russia rouble
SAR Saudi Arabia riyal
SGD Singapore dollar
SIT Slovenia tolar
SKK Slovakia koruna
THB Thailand baht
TRL Turkey lira
TRY Turkey new lira
USD US dollar
ZAR South Africa rand
{"inline_keyboard":[[{"text":"Text des Buttons","url":"https://google.com"}]]}

How to install Pepperflash for Firefox (Ubuntu 14.04+)

Install Freshwrapper

You must install the Freshwrapper, because Firefox doesn't support the Pepper API. There are two ways: install from PPA (recommended) or from source.

Install from PPA (recommended)

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install freshplayerplugin

Source

Install from source

sudo apt-get install build-essential git cmake pkg-config libglib2.0-dev libasound2-dev libx11-dev libgl1-mesa-dev liburiparser-dev libcairo2-dev libpango1.0-dev libpangocairo-1.0-0 libpangoft2-1.0-0 libfreetype6-dev libgtk2.0-dev libxinerama-dev libconfig-dev libevent-dev libegl1-mesa-dev libgles2-mesa-dev ragel
git clone https://github.com/i-rinat/freshplayerplugin.git
cd freshplayerplugin
mkdir build
cd build
cmake ..
make
cp libfreshwrapper-pepperflash.so ~/.mozilla/plugins

Install Pepperflash

Now you need to install the Pepperflash Plugin. There are two ways.

Install Google Chrome (Stable/Beta/Unstable) (recommended)

Download Google Chrome Stable, Beta or Unstable. That's it!

Correct Google Chrome Unstable path

sudo ln -s /opt/google/chrome/PepperFlash /opt/google/chrome-unstable/PepperFlash

Install pepperflashplugin-nonfree

ATTENTION: The Pepperflash plugin WON'T be updated automatically! You have to update it manually!

sudo apt-get install pepperflashplugin-nonfree
sudo update-pepperflashplugin-nonfree --install

You can even use beta and dev versions of the plugin by adding --beta or --unstable.

Configure plugin (optional)

You can skip this step and you are done! Configure the freshwrapper to enable 3d support for example. Download this file and save it to ~/.config/freshwrapper.conf.

do
-- HOW TO USE:
-- 1. Go to the Google Developers Console.
-- 2. Select/Create a project.
-- 3. In the sidebar on the left, select APIs & auth. In the list of APIs, choose "YouTube Data API" an make sure the status is ON for the YouTube Data API v3.
-- 4. In the sidebar on the left, select Credentials.
-- 5. Generate an API-Key (browser key, leave the referer field blank)
-- 6. Write your API key in this file at local apikey=
-- Your quota is 50.000.000 per day and a search takes 100 points. So if you manage to use this in one day, you're a real spammer :P
local function get_yt_data (yt_code)
local base_url = 'http://gdata.youtube.com/feeds/api/'
local url = base_url..'/videos/'..yt_code..'?v=2&alt=jsonc'
local res,code = http.request(url)
if code ~= 200 then return "HTTP ERROR" end
local data = json:decode(res).data
return data
end
local function format_youtube_data(data, link)
local title = data.title
local uploader = data.uploader
local viewCount = data.viewCount
local text = title..'\n(uploaded by: '..uploader..', seen '..viewCount..' times)\n'
send_msg(receiver, text, ok_cb, false)
end
local function searchYoutubeVideo(text)
local apikey = "putyourapikeyhere"
local data = httpsRequest('https://www.googleapis.com/youtube/v3/search?part=snippet&key='..apikey..'&maxResults=1&type=video&q=' .. URL.escape(text))
if not data then
print("HTTP error")
return nil
elseif not data.items[1] then
return "YouTube video not found!"
end
videoId = data.items[1].id.videoId
videoURL = 'https://youtube.com/watch?v='..videoId
return videoURL
end
function httpsRequest(url)
local res,code = https.request(url)
if code ~= 200 then return nil end
return json:decode(res)
end
function run(msg, matches)
local text = msg.text:sub(string.len(matches[1]) + 1,-1)
local link = searchYoutubeVideo(text)
local yt_code = videoId
local data = get_yt_data(yt_code)
local receiver = get_receiver(msg)
send_youtube_data(data, receiver, link)
return searchYoutubeVideo(text)
end
return {
description = "searches youtube video",
usage = "!youtube [search term]",
patterns = {
"^!youtube",
"^!yt"
},
run = run
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment