Merge branch 'master' of git://github.com/but3k4/telegram-bot into but3k4-master
This commit is contained in:
commit
021d58e62a
59
README.md
59
README.md
@ -11,38 +11,29 @@ Multimedia
|
||||
- When user sends youtube URL, send to origin video image.
|
||||
|
||||
![http://i.imgur.com/0FGUvU0.png](http://i.imgur.com/0FGUvU0.png) ![http://i.imgur.com/zW7WWWt.png](http://i.imgur.com/zW7WWWt.png) ![http://i.imgur.com/zW7WWWt.png](http://i.imgur.com/kPK7paz.png)
|
||||
Command list
|
||||
|
||||
Bot Commands
|
||||
------------
|
||||
```
|
||||
!9gag -> send random image from 9gag
|
||||
!echo [whatever] -> echoes the msg
|
||||
!eur [USD] -> EURUSD market value
|
||||
!uc3m -> Fortunes from Universidad Carlos III
|
||||
!get (value_name) -> retrieves variables saved with !set
|
||||
say hello to [name] -> Says hello to someone
|
||||
!help -> Lists all available commands
|
||||
!img [topic] -> search image with Google API and sends it
|
||||
!ping -> bot sends pong
|
||||
!rae [word] -> Spanish dictionary
|
||||
!set [value_name] [data] -> Set value
|
||||
!stats -> Numer of messages by user
|
||||
!time [area] -> Displays the local time in an area
|
||||
!tw [text] -> Sends a tweet
|
||||
!version -> Shows bot version
|
||||
!weather (city) -> weather in that city (Madrid is default)
|
||||
```
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><strong>Name</strong></td>
|
||||
<td><strong>Description</strong></td>
|
||||
<td><strong>Usage</strong></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr><td>9gag.lua</td><td>9GAG for telegram</td><td>!9gag: Send random image from 9gag</td></tr><tr><td>btc.lua</td><td>Bitcoin global average market value (in EUR or USD)</td><td>!btc [EUR|USD] [amount]</td></tr><tr><td>echo.lua</td><td>echoes the msg</td><td>!echo [whatever]</td></tr><tr><td>eur.lua</td><td>EURUSD market value</td><td>!eur [USD]</td></tr><tr><td>fortunes_uc3m.lua</td><td>Fortunes from Universidad Carlos III</td><td>!uc3m</td></tr><tr><td>get.lua</td><td>retrieves variables saved with !set</td><td>!get (value_name)</td></tr><tr><td>giphy.lua</td><td>GIFs from telegram with Giphy API</td><td>!gif (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.<br>!giphy (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.<br></td></tr><tr><td>google.lua</td><td>Searches Google and send results</td><td>!google [terms]</td></tr><tr><td>gps.lua</td><td>generates a map showing the given GPS coordinates</td><td>!gps latitude,longitude</td></tr><tr><td>hello.lua</td><td>Says hello to someone</td><td>say hello to [name]</td></tr><tr><td>help.lua</td><td>Lists all available commands</td><td>!help<br>!help md<br></td></tr><tr><td>images.lua</td><td>When user sends image URL (ends with png, jpg, jpeg) download and send it to origin.</td><td></td></tr><tr><td>img_google.lua</td><td>search image with Google API and sends it</td><td>!img [topic]</td></tr><tr><td>invite.lua</td><td>Invite other user to the chat group</td><td>!invite name [user_name]<br>!invite id [user_id]<br></td></tr><tr><td>location.lua</td><td>Gets information about a location, maplink and overview</td><td>!loc (location)</td></tr><tr><td>media.lua</td><td>When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.</td><td></td></tr><tr><td>ping.lua</td><td>If domain is offline, send msg to peer</td><td></td></tr><tr><td>plugins.lua</td><td>Enables, disables and reloads plugins. Privileged users only.</td><td>!plugins: list all plugins<br>!plugins enable [plugin]<br>!plugins disable [plugin]<br>!plugins reload<br></td></tr><tr><td>rae.lua</td><td>Spanish dictionary</td><td>!rae [word]</td></tr><tr><td>set.lua</td><td>Set value</td><td>!set [value_name] [data]</td></tr><tr><td>stats.lua</td><td>Numer of messages by user</td><td>!stats</td></tr><tr><td>time.lua</td><td>Displays the local time in an area</td><td>!time [area]</td></tr><tr><td>twitter.lua</td><td>When user sends twitter URL, send text and images to origin. Requieres OAuth Key.</td><td></td></tr><tr><td>twitter_send.lua</td><td>Sends a tweet</td><td>!tw [text]</td></tr><tr><td>version.lua</td><td>Shows bot version</td><td>!version</td></tr><tr><td>weather.lua</td><td>weather in that city (Madrid is default)</td><td>!weather (city)</td></tr><tr><td>youtube.lua</td><td>sends YouTube image</td><td></td></tr></tbody></table>
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
```bash
|
||||
# Tested on Ubuntu 14.04, for other OSs check out https://github.com/vysheng/tg#installation
|
||||
$ sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev unzip git
|
||||
$ cd /tmp
|
||||
$ wget http://luarocks.org/releases/luarocks-2.2.0.tar.gz
|
||||
$ tar -xzvf luarocks-2.2.0.tar.gz
|
||||
$ tar -xzvf luarocks-2.2.0.tar.gz
|
||||
$ cd luarocks-2.2.0/
|
||||
$ ./configure
|
||||
$ ./configure
|
||||
$ make && sudo make install
|
||||
$ sudo luarocks install oauth
|
||||
$ sudo luarocks install luasocket
|
||||
@ -52,12 +43,30 @@ $ sudo luarocks install luasocket
|
||||
$ cd $HOME
|
||||
$ git clone https://github.com/yagop/telegram-bot.git --recursive
|
||||
$ cd telegram-bot/tg
|
||||
$ ./configure && make
|
||||
$ cd ..
|
||||
$ ./configure && make && cd ..
|
||||
$ ./launch.sh # Will ask you for a phone number & confirmation code.
|
||||
```
|
||||
|
||||
Enable more [`plugins`](https://github.com/yagop/telegram-bot/tree/master/plugins)
|
||||
-------------
|
||||
See the plugins list with `!plugins` command.
|
||||
|
||||
Enable a disabled plugin by `!plugins enable [name]`.
|
||||
|
||||
Disable an enabled plugin by `!plugins disable [name]`.
|
||||
|
||||
Those commands require a privileged user, privileged users are defined inside `data/config.lua` (generated by the bot), stop de bot and edit if necessary.
|
||||
|
||||
|
||||
Run it as a daemon
|
||||
------------
|
||||
If your linux/unix comes with [upstart](http://upstart.ubuntu.com/) you can run the bot by this way
|
||||
```bash
|
||||
$ sed -i "s/yourusername/$(whoami)/g" etc/telegram.conf
|
||||
$ sed -i "s_telegrambotpath_$(pwd)_g" etc/telegram.conf
|
||||
$ sudo cp etc/telegram.conf /etc/init/
|
||||
$ ./launch.sh # Will ask you for a phone number & confirmation code.
|
||||
$ sudo start telegram # To start it
|
||||
$ sudo stop telegram # To stop it
|
||||
```
|
||||
|
||||
Contact me
|
||||
|
@ -5,7 +5,7 @@ json = (loadfile "./libs/JSON.lua")()
|
||||
serpent = (loadfile "./libs/serpent.lua")()
|
||||
require("./bot/utils")
|
||||
|
||||
VERSION = '0.8.3'
|
||||
VERSION = '0.8.4'
|
||||
|
||||
function on_msg_receive (msg)
|
||||
vardump(msg)
|
||||
@ -209,4 +209,4 @@ end
|
||||
|
||||
-- Start and load values
|
||||
our_id = 0
|
||||
now = os.time()
|
||||
now = os.time()
|
||||
|
@ -61,12 +61,23 @@ local function get_stats_status( msg )
|
||||
-- vardump(stats)
|
||||
local text = ""
|
||||
local to_id = tostring(msg.to.id)
|
||||
local rank = {}
|
||||
|
||||
for id, user in pairs(_stats[to_id]) do
|
||||
table.insert(rank, user)
|
||||
end
|
||||
table.sort(rank, function(a, b)
|
||||
if a.msg_num and b.msg_num then
|
||||
return a.msg_num > b.msg_num
|
||||
end
|
||||
end
|
||||
)
|
||||
for id, user in pairs(rank) do
|
||||
print(">> ", id, user.name)
|
||||
if user.last_name == nil then
|
||||
text = text..user.name.." ["..id.."]: "..user.msg_num.."\n"
|
||||
text = text..user.name..": "..user.msg_num.."\n"
|
||||
else
|
||||
text = text..user.name.." "..user.last_name.." ["..id.."]: "..user.msg_num.."\n"
|
||||
text = text..user.name.." "..user.last_name..": "..user.msg_num.."\n"
|
||||
end
|
||||
end
|
||||
print("usuarios: "..text)
|
||||
@ -75,7 +86,7 @@ end
|
||||
|
||||
local function run(msg, matches)
|
||||
if matches[1] == "stats" then -- Hack
|
||||
return get_stats_status(msg)
|
||||
return get_stats_status(msg)
|
||||
else
|
||||
print ("update stats")
|
||||
update_user_stats(msg)
|
||||
@ -86,7 +97,7 @@ end
|
||||
_stats = read_file_stats()
|
||||
|
||||
return {
|
||||
description = "Numer of messages by user",
|
||||
description = "Number of messages by user",
|
||||
usage = "!stats",
|
||||
patterns = {
|
||||
".*",
|
||||
@ -95,4 +106,4 @@ return {
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user