Giter VIP home page Giter VIP logo

telegram-bot's Introduction

⚠️ UNMAINTAINED / DEPRECATED ⚠️

This proyect is no longer active since Telegram Bot API creation. It's better using the API rather than telegram-bot, almost every feature on Telegram-cli is available on API. You can use node-telegram-bot-api Node.js module if you want. Or search your favourite one here.

telegram-bot

https://yago.me/tg-bot https://telegram.me/Yago_Perez https://gitter.im/yagop/telegram-bot Donate button

A Telegram Bot based on plugins using tg.

Multimedia

  • When user sends image (png, jpg, jpeg) URL download and send it to origin.
  • When user sends media (gif, mp4, pdf, etc.) URL download and send it to origin.
  • When user sends twitter URL, send text and images to origin. Requires OAuth Key.
  • When user sends YouTube URL, send to origin video image.

http://i.imgur.com/0FGUvU0.png http://i.imgur.com/zW7WWWt.png http://i.imgur.com/zW7WWWt.png

Bot Commands

Name Description Usage
9gag.lua 9GAG for telegram !9gag: Send random image from 9gag
boobs.lua Gets a random boobs or butts pic !boobs: Get a boobs NSFW image. 🔞
!butts: Get a butts NSFW image. 🔞
btc.lua Bitcoin global average market value (in EUR or USD) !btc [EUR|USD] [amount]
bugzilla.lua Lookup bugzilla status update /bot bugzilla [bug number]
calculator.lua Calculate math expressions with mathjs API !calc [expression]: evaluates the expression and sends the result.
channels.lua Plugin to manage channels. Enable or disable channel. !channel enable: enable current channel
!channel disable: disable current channel
danbooru.lua Gets a random fresh or popular image from Danbooru !danbooru - gets a random fresh image from Danbooru 🔞
!danboorud - random daily popular image 🔞
!danbooruw - random weekly popular image 🔞
!danboorum - random monthly popular image 🔞
dogify.lua Create a doge image with words. !dogify (words/or phrases/separated/by/slashes) - Create a doge image with the words.
download_media.lua When bot receives a media msg, download the media.
echo.lua Simplest plugin ever! !echo [whatever]: echoes the msg
eur.lua Real-time EURUSD market price !eur [USD]
expand.lua Expand a shorten URL to the original. !expand [url]
fortunes_uc3m.lua Fortunes from Universidad Carlos III !uc3m
get.lua Retrieves variables saved with !set !get (value_name): Returns the value_name value.
giphy.lua GIFs from telegram with Giphy API !gif (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.
!giphy (term): Search and sends GIF from Giphy. If no param, sends a trending GIF.
gnuplot.lua Gnuplot plugin !gnuplot [single variable function]: Plot single variable function.
google.lua Searches Google and send results !google [terms]: Searches Google and send results
gps.lua generates a map showing the given GPS coordinates !gps latitude,longitude: generates a map showing the given GPS coordinates
hackernews.lua Show top 5 hacker news (ycombinator.com) !hackernews
hello.lua Says hello to someone say hello to [name]
help.lua Help plugin. Get info from other plugins. !help: Show list of plugins.
!help all: Show all commands for every plugin.
!help [plugin name]: Commands for that plugin.
id.lua Know your id or the id of a chat members. !id: Return your ID and the chat id if you are in one.
!id(s) chat: Return the IDs of the chat members.
images.lua When user sends image URL (ends with png, jpg, jpeg) download and send it to origin.
imdb.lua IMDB plugin for Telegram !imdb [movie]
img_google.lua Search image with Google API and sends it. !img [term]: Random search an image with Google API.
invite.lua Invite other user to the chat group !invite name [user_name]
!invite id [user_id]
isup.lua Check if a website or server is up. !isup [host]: Performs a HTTP request or Socket (ip:port) connection
!isup cron [host]: Every 5mins check if host is up. (Requires privileged user)
!isup cron delete [host]: Disable checking that host.
location.lua Gets information about a location, maplink and overview !loc (location): Gets information about a location, maplink and overview
magic8ball.lua Magic 8Ball !magic8ball
media.lua When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.
meme.lua Generate a meme image with up and bottom texts. !meme search (name): Return the name of the meme that match.
!meme list: Return the link where you can see the memes.
!meme listall: Return the list of all memes. Only admin can call it.
!meme [name] - [text_up] - [text_down]: Generate a meme with the picture that match with that name with the texts provided.
!meme [name] "[text_up]" "[text_down]": Generate a meme with the picture that match with that name with the texts provided.
minecraft.lua Searches Minecraft server and sends info !mine [ip]: Searches Minecraft server on specified IP and sends info. Default port: 25565
!mine [ip] [port]: Searches Minecraft server on specified IP and port and sends info.
pili.lua Shorten an URL with pili.la service !pili [url]: Short the url
plugins.lua Plugin to manage other plugins. Enable, disable or reload. !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.
qr.lua Given a text it returns a qr code !qr [text] : returns a black and white qr code
!qr "[background color]" "[data color]" [text] : returns a colored qr code (see !help qr to see how specify colors).
quotes.lua Quote plugin, you can create and retrieves random quotes !addquote [msg]
!quote
rae.lua Spanish dictionary !rae [word]: Search that word in Spanish dictionary.
roll.lua Roll some dice! !roll d | d
rss.lua Manage User/Chat RSS subscriptions. !rss: Get the rss subscriptions.
!rss subscribe (url): Subscribe to that url.
!rss unsubscribe (id): Unsubscribe of that id.
!rss sync: Sync the rss subscriptios now. Only sudo users can use this option.
search_youtube.lua Search video on YouTube and send it. !youtube [term]: Search for a YouTube video and send it.
set.lua Plugin for saving values. get.lua plugin is necessary to retrieve them. !set [value_name] [data]: Saves the data with the value_name name.
stats.lua Plugin to update user stats. !stats: Returns a list of Username [telegram_id]: msg_num
steam.lua Grabs Steam info for Steam links.
tex.lua Convert LaTeX equation to image !tex [equation]: Convert LaTeX equation to image
time.lua Displays the local time in an area !time [area]: Displays the local time in that area
translate.lua Translate some text !translate text. Translate the text to English.
!translate target_lang text.
!translate source,target text
tweet.lua Random tweet from user !tweet id [id]: Get a random tweet from the user with that ID
!tweet id [id] last: Get a random tweet from the user with that ID
!tweet name [name]: Get a random tweet from the user with that name
!tweet name [name] last: Get a random tweet from the user with that name
twitter.lua When user sends twitter URL, send text and images to origin. Requires OAuth Key.
twitter_send.lua Sends a tweet !tw [text]: Sends the Tweet with the configured account.
version.lua Shows bot version !version: Shows bot version
vote.lua Plugin for voting in groups. !voting reset: Reset all the votes.
!vote [number]: Cast the vote.
!voting stats: Shows the statistics of voting.
weather.lua weather in that city (Madrid is default) !weather (city)
webshot.lua Take an screenshot of a web. !webshot [url]
wiki.lua Searches Wikipedia and send results !wiki [terms]: Searches wiki and send results
!wiki_set [wiki]: sets the wikimedia site for this chat
!wiki_get: gets the current wikimedia site
xkcd.lua Send comic images from xkcd !xkcd (id): Send an xkcd image and title. If not id, send a random one
youtube.lua Sends YouTube info and image.
# Tested on Ubuntu 14.04, for other OSs check out https://github.com/yagop/telegram-bot/wiki/Installation
sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev make unzip git redis-server g++ libjansson-dev libpython-dev expat libexpat1-dev
# After those dependencies, lets install the bot
cd $HOME
git clone https://github.com/yagop/telegram-bot.git
cd telegram-bot
./launch.sh install
./launch.sh # Will ask you for a phone number & confirmation code.

Enable more 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 the bot and edit if necessary.

Run it as a daemon

If your Linux/Unix comes with upstart you can run the bot by this way

$ 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/
$ sudo start telegram # To start it
$ sudo stop telegram # To stop it

Contact me

You can contact me via Telegram but if you have an issue please open one.

Join on the TelegramBot Discussion Group.

telegram-bot's People

Contributors

ariefbayu avatar asdofindia avatar bb010g avatar bo0tzz avatar cameri avatar cheatcoder avatar devpgsv avatar gitter-badger avatar ingria avatar javierhonduco avatar julioc avatar mamal72 avatar mrvdb avatar niteshjain avatar ollpu avatar pothix avatar robingroppe avatar rockneurotiko avatar shittyadvice avatar soend avatar ssut avatar surye avatar timku avatar walkman100 avatar wvanbreukelen avatar xlopo avatar yagop avatar yeah568 avatar ypcat avatar zhaofengli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegram-bot's Issues

launch.sh does not work for me, help!

I did all what the readme said but when i execute .launch.sh.... appears this text

> telegram-cli: tgl/mtproto-client.c:1247: tc_becomes_ready: Assertion `0' failed.
SIGNAL received
h./tg/bin/telegram-cli(print_backtrace+0x2c)[0x80835ec]
./tg/bin/telegram-cli(termination_signal_handler+0x7d)[0x808368d]
[0xb770cd28]
[0xb770cd4c]
/lib/i386-linux-gnu/libc.so.6(gsignal+0x47)[0xb72ea607]
/lib/i386-linux-gnu/libc.so.6(abort+0x143)[0xb72eda33]
/lib/i386-linux-gnu/libc.so.6(+0x27757)[0xb72e3757]
/lib/i386-linux-gnu/libc.so.6(+0x27807)[0xb72e3807]
./tg/bin/telegram-cli[0x8098bf4]
./tg/bin/telegram-cli[0x80c979e]
/usr/lib/i386-linux-gnu/libevent-2.0.so.5(event_base_loop+0x6f4)[0xb76bb234]
./tg/bin/telegram-cli(net_loop+0xc0)[0x80849c0]
./tg/bin/telegram-cli(loop+0x1bf)[0x808617f]
./tg/bin/telegram-cli(inner_main+0x17)[0x8082d97]
./tg/bin/telegram-cli(main+0x2fb)[0x8081e4b]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb72d5a83]
./tg/bin/telegram-cli[0x8081f51]

any idea?

Stats plugin crashes on high load

Problem: my bot is used very intensively. So at one moment the stats.lua file becomes so big that it cannot be written into anymore. Because of some reason it becomes empty and the following error occurs:

2015-02-07 23 31 58

So i suggest using sqlite for storing stats.

I can't trigger the plugins as a bot

Hi,

Isn't it allowed for a user who also is a bot to trigger the plugins? It seems that the msg_valid function returns false in the following if:

if msg.out then
   return false
end

Preguntas

Ya tengo el bot funcionando, muy bueno para el ocio y util también pero tengo las siguientes preguntas:
¿Donde se guarda imagenes del Bot, todo lo que descarga y carga en el Telegram?
¿Como puedo configurar lo de Twitter? Me sale el siguiente mensaje: You aren't allowed to send tweets
¿Que viene siendo el comando set y get?

Edit: Otra pregunta, ¿cómo podría dejar el bot en modo background? Podría usar el screen pero mejor preguntar antes.

Latest version crashes

The version crashes with:

telegram-cli: tgl/queries.c:148: tglq_send_query_ex: Assertion `DC->auth_key_id' failed.
SIGNAL received
h./tg/bin/telegram-cli(print_backtrace+0x20)[0x4437d0]
./tg/bin/telegram-cli(termination_signal_handler+0x64)[0x443854]
/lib/x86_64-linux-gnu/libc.so.6(+0x36d40)[0x7f711324bd40]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x39)[0x7f711324bcc9]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x148)[0x7f711324f0d8]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fb86)[0x7f7113244b86]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fc32)[0x7f7113244c32]

Happens on Ubuntu 14.04.

Anyone else has it?

rae not working

It seems that the call to the api http://dulcinea.herokuapp.com/api/?query= in plugins/rae.lua is not working.

"Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details."

Particular Messages support?

There is a way to send a particular message to a specific person?
I have the bot added in a group conversation and I want to write a plugin that sends a PM when a username is cited.

Thanks

Send voice message

Is it possible to send audio files as voice messages? I know that there is a send_document() function, but this function just displays the download button on the client, not the play button.

how to use send_photo() to send sticker (webp file)

The following codes is purposed to send custom sticker. However, I'm not sure why send_photo() doesn't deliver the image :(.

function run(msg, matches)

print ("processing sticker " .. matches[1])

local response = ""
local rootpath = "/home/ariefbayu/telegram-bot/stickers/reps/"

local sticker_pairs = {
    ["smile"]="ladysmile",
    ["awesome"]="ras-awesome",
    ["sad"]="belu-sad"
}

print (" matched: " .. sticker_pairs[ matches[1] ])

  for k, v in pairs(sticker_pairs) do
    print("checking sticker", k)

    if k == matches[1] then

        if messageToAllowed(msg.to.id) == false then

            return ""

        end


        local receiver = get_receiver(msg)
        local file_path = rootpath .. sticker_pairs[ matches[1] ] .. ".webp"
        print(file_path)
        if file_exists(file_path) == true then


            response = matches[1]

            local cb_extra = {
                file_path = file_path,
                cb_function = cb_function,
                cb_extra = cb_extra
            }
            -- Call to remove with optional callback
            -- send_photo(receiver, file_path, rmtmp_cb, cb_extra)

            send_photo(receiver, file_path, ok_cb, cb_extra)
        else
            response = "sticker is missing..."
        end
        break

    end

  end


    return response
end

function messageToAllowed(id)
local response = true

return response
end

return {
    description = "load custom stickers", 
    usage = "/sticker [sticker-name]",
    patterns = {
            "^/sticker (.*)$"
        }, 
    run = run 
}

Twitter 401

Bot is working great, all but the twitter part.
I've installed oauth and other dependancies. Created an app on twitter, generated keys and secrets, etc.
Gave the app permissions, but still getting 401 errors.
Tried changing system time, callback, or none, giving login perms to app, but still unable to post.

Any ideas?

!stats not working.

This command is not working only for me? I was running modified bot.lua and utils.lua, and thought it was my fault, but it seem that it isn't working with your files as well.

It records users stats, but the command won't work. Can you reproduce this?

Use command stack

In some cases bot crashes because the previous task is not completed yet (for example, see #36).

[52%Up]> telegram-cli: tgl/queries.c:1635: send_part: Assertion `f->part_size == x' failed.

I suggest adding command stack, something like peer|command|timestamp, so that all commands will be executed successively.

Especificar persona que puede usar el comando

Hola, estoy probando este genial bot y me ha encantado.
El problema es que no consigo limitar el uso de comando a x persona, ya que me gustaría introducir el estado de la ram, discos duros, y demas, y no quiero que esos comandos lo vayan a poder utilizar un tercero.

¿Como lo podria usar?

Gracias!

Cannot install luasocket

Having problem on installing luasocket, error log here:

$ ./launch.sh
Telegram-cli version 1.1.1, Copyright (C) 2013-2014 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
I: config dir=[/root/.telegram-cli]
 *** lua: /usr/share/lua/5.1/socket.lua:12: module 'socket.core' not found:
        no field package.preload['socket.core']
        no file './socket/core.lua'
        no file '/usr/share/lua/5.1/socket/core.lua'
        no file '/usr/share/lua/5.1/socket/core/init.lua'
        no file '/usr/lib64/lua/5.1/socket/core.lua'
        no file '/usr/lib64/lua/5.1/socket/core/init.lua'
        no file './socket/core.so'
        no file '/usr/lib64/lua/5.1/socket/core.so'
        no file '/usr/lib64/lua/5.1/loadall.so'
        no file './socket.so'
        no file '/usr/lib64/lua/5.1/socket.so'
        no file '/usr/lib64/lua/5.1/loadall.so'

Also I have tried to find the files, only the core.so return results:

# find / -name core.lua
# find / -name init.lua
# find / -name core.so
/usr/lib/lua/5.1/socket/core.so
/usr/lib/lua/5.1/mime/core.so
/usr/local/lib/lua/5.1/socket/core.so
/usr/local/lib/lua/5.1/mime/core.so
# find / -name loadall.so
# find / -name socket.so

Any suggestion or idea what I should do to fix this?

Request: plugin setting to set response message to the user

A user to call a plugin command in the group, you can get your answer in private/direct message.
The ability to set some plugins to direct the response outside the group which the user requested message. Eg.

In group "Telegram" the user "Bet" request plugin " !help " or " !img ", the response return in private message. Not in group.

Access removed from telegram

I wanted to change the number (user) the telegram bot was using. So I revoked access to the bot from my number. Now I can't setup a new number anymore. What can I do to fix this? Tried reinstalling it but that didn't do anything. Are the user settings saved elsewhere?

Peticion cliente RSS / Petition client RSS

Spanish:

Hola, tengo una petición que es un plugin que obtenga por RSS nuevo contenido en paginas web y mande un mensaje en una conversación el contenido. No tengo ni idea como se haría y seria bastante útil por si alguien se anima, le agradecería mucho.

Gracias

English:

Hii, I have a request which is a plugin to get new content via RSS web pages and send a message in a conversation content. I have no idea as you would and would be quite useful if anyone is encouraged, we appreciate it. Sorry my english.

Thanks.

Prevent messages from being marked as read

Hello,

I've deployed your program on my raspi, but I have the problem, that my raspi marks my messages as read all the time, althoug I didn't read them at all. It is clear to me why this happens, but I don't know how to prevent the bot from doing this. Is there a simple way to fix this? (Maybe you can only mark messages as read to which a pattern matches)

Plugins y Comandos

Bueno tengo la intención de crear un plugin para deshabilitar todos los comandos para ciertos usuarios, ¿cómo podría hacerlo?

URL title grabber plugin

Add plugin that grabs <title> tag contents from pages in URL's and post it to the Telegram groups.

problem with luasocket

First of all: Thank you for your github contrib!

I have a small problem. Everytime I start the script, it end with errors:

*** lua: ./bot/bot.lua:1: module 'socket.http' not found: no field package.preload['socket.http'] no file '/usr/local/share/lua/5.2/socket/http.lua' no file '/usr/local/share/lua/5.2/socket/http/init.lua'

Telegram Bot

I am sorry for opening it up here but i just wanted your skype id (regarding Telegram Bot)

Issue installing bot (sed command)

Hi,
After running sed -i "s/yourusername/$(whoami)/g" etc/telegram.conf
I get: sed: 1: "etc/telegram.conf": invalid command code e.

Any ideas?

Sending messages

Hi there!

Firstly, seriously nice work with this, It's totally reliable and simple to script for.
However I have a small issue. I'm wanting to push alerts to the process, and have the bot read them.

I've started by creating an API where the bot can check the alerts and if one exists it posts it in the chat however I need to make this check every n'th minute or second.

How can i create a plugin that checks every x, without it looking for a users interaction or input via the chat.

Cheers
Dan.

How do i get username ?

Hi ,

Telegram-bot is great & really helpful !

Now i know user_info command in tg can give username . So how do i get username in telegram-bot , is there a interface in telegram-bot execute tg commands ( like user_info ) , or are there any other means to achieve this ?

thanks !

Errors in img module

When there are a lot of simultaneous requests, the module fails with that errors:

[03:35]  Дарья >>> !img black hole
[52%Up]> telegram-cli: tgl/queries.c:1635: send_part: Assertion `f->part_size == x' failed.
SIGNAL received
h./tg/bin/telegram-cli(print_backtrace+0x20)[0x43eed0]
./tg/bin/telegram-cli(termination_signal_handler+0x64)[0x43ef54]
/lib/x86_64-linux-gnu/libc.so.6(+0x36c30)[0x7f86562bac30]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x39)[0x7f86562babb9]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x148)[0x7f86562bdfc8]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fa76)[0x7f86562b3a76]
/lib/x86_64-linux-gnu/libc.so.6(+0x2fb22)[0x7f86562b3b22]
./tg/bin/telegram-cli[0x4578a9]
./tg/bin/telegram-cli[0x4579ca]
./tg/bin/telegram-cli(tglq_query_result+0xec)[0x458e9c]
./tg/bin/telegram-cli[0x451f93]
./tg/bin/telegram-cli[0x4519eb]
./tg/bin/telegram-cli[0x452bff]
./tg/bin/telegram-cli[0x479f0b]
/usr/lib/x86_64-linux-gnu/libevent-2.0.so.5(event_base_loop+0x754)[0x7f86572cdf24]
./tg/bin/telegram-cli(net_loop+0x7b)[0x44020b]
./tg/bin/telegram-cli(main_loop+0x10)[0x440460]
./tg/bin/telegram-cli(loop+0x4b7)[0x4418a7]
./tg/bin/telegram-cli(main+0x286)[0x43da66]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f86562a5ec5]
./tg/bin/telegram-cli[0x43db4e]

I think that this error happens when one requests the image while another image is being downloaded.

Also it freezes if the image is failed to download (for example, 404 error)

Update: this bot has to have some kind of stack for all request, i'll open anotner issue.

Reenviar mensajes a un usuario / Forward messages to any user

Buenas:

Estoy intentando escribir un plugin que sea capaz de reenviar un mensaje recibido al usuario que lo haya ejecutado.

Me explico, un plugin que ejecute el comando de Telegram-CLI: fwd user msg_id siendo user el valor que devuelva msg.from.print_name, y msg_id un número entero que identifique un mensaje cualquiera que haya recibido el cliente.

He probado usando la función: fwd_msg(msg.from.print_name, 4, ok_cb, false), función que he visto dentro de la documentación de tg, pero no devuelve ningún mensaje (el 4 es un ejemplo). Aparentemente no es la función correcta. ¿De qué forma puedo reenviar mensajes a través de un plugin?

Gracias :)

Summary: how can I forward messages from a plugin?

Disabling commands

Hey,
First of all kudos for making awesome bot 👍
I want to make feature that i can disable certain commands for certain chats. Best way is it to solve with plugin? And where i can get chat id? Can i get like 'user#id'..user_id ?

Provision for cleanup of downloaded files

Media files are now downloaded to /tmp but never cleaned. After telegram uploads the downloaded stuff there is no real reason to leave them around, is there?

An additon in the bot.lua file like this could resolve this:

-- Callback to remove tmp files
  function rmtmp_cb(file_path, success, result)
     os.remove(file_path)
  end

function download_to_file( url )
    print("url a descargar: "..url)
    req, c, h = http.request(url)
    htype = h["content-type"]
    vardump(c)
    print("content-type: "..htype)
    if htype == "image/jpeg" then
      file_name = string.random(5)..".jpg"
      file_path = "/tmp/"..file_name
    else
      if htype == "image/gif" then
        file_name = string.random(5)..".gif"
        file_path = "/tmp/"..file_name
      else
        if htype == "image/png" then
          file_name = string.random(5)..".png"
          file_path = "/tmp/"..file_name
        else
          file_name = url:match("([^/]+)$")
          file_path = "/tmp/"..file_name
        end
      end
    end
    file = io.open(file_path, "w+")
    file:write(req)
    file:close()

    -- Schedule a cleanup callback
   postpone(rmtmp_cb, file_path, config.tmpcleanup_delay)
    return file_path
  end

Something like 10 or 20 seconds should be enough.
What do you think?

Petition: !addquote

Usage: !addquote remarcable text
Description: Save "remarcable text" in a file with date and chat name.

Thanks

Cant launch bot

When I run ./launch, this came out

            Loading plugin  9gag.lua
            Loading plugin  btc.lua
            Loading plugin  echo.lua
            Loading plugin  eur.lua
            Loading plugin  fortunes_uc3m.lua
            Loading plugin  get.lua
            Loading plugin  gps.lua
            Loading plugin  hello.lua
            Loading plugin  help.lua
            Loading plugin  images.lua
            Loading plugin  img_google.lua
            Loading plugin  location.lua
            Loading plugin  media.lua
            Loading plugin  ping.lua
            Loading plugin  rae.lua
            Loading plugin  reload.lua
            Loading plugin  set.lua
            Loading plugin  stats.lua
            Loading plugin  time.lua
            Loading plugin  twitter.lua
            Loading plugin  twitter_send.lua
            Loading plugin  version.lua
            Loading plugin  weather.lua
            Loading plugin  youtube.lua
            > telegram-cli: loop.c:334: get_difference_callback: Assertion `success' failed.
            SIGNAL received
            h./tg/bin/telegram-cli(print_backtrace+0x1c)[0x4402ec]
            ./tg/bin/telegram-cli(termination_signal_handler+0x64)[0x440374]
            /lib/x86_64-linux-gnu/libc.so.6(+0x36150)[0x7f504c180150]
            /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35)[0x7f504c1800d5]
            /lib/x86_64-linux-gnu/libc.so.6(abort+0x17b)[0x7f504c18383b]
            /lib/x86_64-linux-gnu/libc.so.6(+0x2ed9e)[0x7f504c178d9e]
            /lib/x86_64-linux-gnu/libc.so.6(+0x2ee42)[0x7f504c178e42]
            ./tg/bin/telegram-cli(export_auth_callback+0x0)[0x440a60]
            ./tg/bin/telegram-cli[0x454935]
            ./tg/bin/telegram-cli(tglq_query_error+0x147)[0x45a807]
            ./tg/bin/telegram-cli[0x453a15]
            ./tg/bin/telegram-cli[0x454592]
            ./tg/bin/telegram-cli[0x47ea0d]
            /usr/lib/libevent-2.0.so.5(event_base_loop+0x20c)[0x7f504d38f94c]
            ./tg/bin/telegram-cli(net_loop+0x7b)[0x44167b]
            ./tg/bin/telegram-cli(loop+0x433)[0x442cb3]
            ./tg/bin/telegram-cli(main+0x283)[0x43eea3]
            /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f504c16b76d]
            ./tg/bin/telegram-cli[0x43ef8d]

Return os.execute

¡Buenas! Estoy probando a que al mandar un !ram me devuelva una función os.execute, pero me salta un error lo haga de la forma que lo haga:
*** lua: ./bot/bot.lua:77: bad argument #1 to 'len' (string expected, got boolean)

Mi código es el siguiente, ¡muchas gracias!

function run(msg, matches)
    local receiver = get_receiver(msg)
    print('receiver: '..receiver)
    return os.execute("free -g | awk '/^Mem:/{print $4}'")
end

return {
    description = "RAM Libre", 
    usage = "!ram",
    patterns = {"^!ram$"}, 
    run = run 
}

Imagino que será porque os.execute devuelve un true / false y es lo que el bot trata de mostrar, en vez del output real.

Add anti-spam protection?

I really love your bot! Could you add an anti-spam protection, so that the same user can use e.g. !echo only every 5-10 seconds or so? A customized interval would be cool, too!

gcc: internal compiler error: Killed (program cc1)

gcc -I. -I. -g -O2 -I/usr/local/include -I/usr/include -I/usr/include -I/usr/include/lua5.2 -DHAVE_CONFIG_H -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/auto/auto.d -MQ objs/auto/auto.o -o objs/auto/auto.o auto/auto.c
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See file:///usr/share/doc/gcc-4.7/README.Bugs for instructions.
make: *** [objs/auto/auto.o] Error 4

Change name

Is it possible to change the bots name via a config file?
Or maybe talk as the bot while logged in via SSH (from inside the daemon)?

Allow disabling plugins

I'm contemplating writing something which allows disabling plugins. This would make deployment (for me at least) a lot easier.

Something along these lines:

  • move bot/config.json to /etc/config.json.sample
  • write instructions for user to create a config.json file
  • have a construct in the config file which allows to disable plugins, for example, something like:
...
"disable" : {
    "youtube.lua": true,
   "rae.lua"
},
...

And have the loading of plugins and the !reload command use that.

Thoughts?

msg.from.id returns nil

Hi, I'm unable to use the msg.from.id in my plugin, am I missing something?

Thanks in advance, greetings from Brazil.

Missing dependency

Not really an issue but rather a comment on the installation instructions -- luarocks uses unzip, which at least on my Ubuntu Server VMs is not installed by default, so you might want to add it to the apt-get install line.

If you do not have unzip installed, you get errors like this one:

$ sudo luarocks install oauth
Warning: Failed searching manifest: Failed extracting manifest file
Installing https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/oauth-0.0.6-1.src.rock...
Using https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/oauth-0.0.6-1.src.rock... switching to 'build' mode

Error: Failed unpacking rock file: /tmp/luarocks_luarocks-rock-oauth-0.0.6-1-6405/oauth-0.0.6-1.src.rock

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.