Giter Club home page Giter Club logo

holysee's Introduction

Holysee

Build Status codecov

Thought out badly, understood worse and written the worst, this should be a telegram<->irc relay bot with a reasonable configuration.

DISCLAIMER: anything that can ever come from this package is pure garbage. Only a madman would ever learn or study this package. You have been warned.

Dependencies

This abomination uses the excellent telegram-bot library by vendoring a copy of it - to avoid depending on the latest git - in the vendor/ directory. Many thanks to the original authors for their excellent job.

Configuration

The provided configuration file is pretty self explanatory, just copy it to config/local.toml for it to be loaded by the bot during startup.

To convert irc nicknames to telegram and viceversa you can configure the [[nicknames]] map in the toml file as follows:

[[nickanmes]]
irc = "user1"
telegram = "@someother"
[[nicknames]]
irc = "user2"
telegram = "@user2"

In this example remember to add the @ character before the username of the telegram user, or the translation will fail.

There is currently no way of disabling this feature, feel free to find a way of configuring without breaking :)

Enabled commands can be configured as well:

[commands]
data_dir = "./data"
enabled = [
  "karma",
  "quote",
  "last_seen",
  "url_preview",
]

Usage

Stable-ish version

Check Release page, download the prebuild binary (Linux only) and run it with a proper configurations structure:

tar xfvz holysee-$version-linux-amd64.tar.gz
cd holysee
edit config/local.toml
RUST_LOG=holysee=info ./holysee

Git version

Build the bot and run it from where it can access the data dir configured in the toml file:

git clone https://github.com/crisidev/holysee
cd holysee
make
cd holysee
cp config/example.toml config/local.toml
edit config/local.toml
RUST_BACKTRACE=1 RUST_LOG=holysee=debug ./target/debug/holysee

Available Commands and Filters

  • karma
  • last_seen
  • quote
  • url_preview

The commands are run via any transport, using a configurable prefix, like:

!command param1 param2 ...

Help / Usage

Every command is provided with a self-explaining help which will be sent, where possible, as private message to the requester. It is always enabled.

!help command
!usage command

Note: !usage and !help are aliased.

Relay

Relay is a special command allowing IRC <-> Telegram relay. It is always enabled and triggered on every message.

Karma

Karma records string karma for posterity. To create (or increment) the karma of any string you can run:

  • viva <string> or <string>++

To decrement it

  • abbasso <string> or <string>--

To view the karma for a string:

  • !karma <string>

Last Seen

The last seen command maintains a timestamp of the last time a user has written some message in the channel. You can see the last time a nickname has said something by running:

  • !seen <nickname>

Quote

The quote command maintains a list of quotes. To get a random quote run

  • !quote

to add a quote use

  • !quote add <string>

to delete a quote use

  • !quote rm <quote_id>
  • !quote rm <string>

to get a specific quote you can run

  • !quote <quote_id>

Url Preview

The url preview command is not properly a command, in the sense that it is not activated by user input, but instead listens on any incoming message and parses it via regexp to extract any URLs in it. For any url it finds it will try to load it and send the Title of the page on the channel.

holysee's People

Contributors

crisidev avatar uovobw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

holysee's Issues

Another ping-timeout-related panic on IRC

when the stream gets killed during negotiation of a new connection, we get a ping error like:

thread '' panicked at 'Stream was already obtained once, and cannot be reobtained.', /checkout/src/libcore/option.rs:839:4

and the stream is not restarted, blocking the process until restarted. ironically, this also loses data as the messages from telegram are read anyway but propagated to nowhere.

Consider supporting NOTICE irc messages to relay to telegram

I am not sure if telegram supports this kind of things (from a rapid look at the doc it appears not), but at the moment we have the travis-ci bot logging in a test channel and writing the output of the build via a notice. it MIGHT be useful to have another configuration option, for example relay_notice, that only applies to irc (?) that, honouring the allow_receive directive, sends this kind of messages to the telegram channel as well.

UrlPreviewCommand does not honor allow_receive

A mesage sent with allow_receive on telegram set to false will nonetheless relay not the message, but the url preview on the other side, making it confusing and annoying

To reproduce:

  • configure the bot with allow_receive set to false for telegram
  • send a link on irc (with or without the !tg is irrelevant)
  • note the link preview getting written to telegram without the original link

Fix LastSeenCommand when run in query

We need to divide LastSeen in 2 parts:

  1. A filter running on all messages and updating the database
  2. An actual command responding to !seen and using stop_processing = true

ironic use of ! breaks the line

if a user sends an ironic line, like

this bot is really !great, i love it

the message is sent to the other transport as

this bot is really, i love it

cause the !<token> is captured

Implement "rant" command

Implement a new command which disable the transport between IRC and Telegram.

!rant something

irc reconnection is not handled correctly

if the bot gets disconnected, via ping timeout for example, it will not handle reconnection on the irc side automatically, instead the irc receiver (and sender) threads will panic with

thread '<unnamed>' panicked at 'The connection timed out due to no ping response.', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/irc-0.12.5/....

i think this is a different bug from the netsplit one as in this case the core.run() call panics and the thread must be restarted anew

Avoid flooding when there is more than one title

Please avoid this:

https://www.economist.com/blogs/johnson/2011/03/italian_worldviews                                                                                                                                    
18:53         -- │ Notice(tapirigram): Dietrologia - Italian worldviews                                                                                                                                                        
18:53         -- │ Notice(tapirigram): the economist                                                                                                                                                                           
18:53         -- │ Notice(tapirigram): down icon                                                                                                                                                                               
18:53         -- │ Notice(tapirigram): down icon                                                                                                                                                                               
18:53         -- │ Notice(tapirigram): user icon                                                                                                                                                                               
18:53         -- │ Notice(tapirigram): down icon                                                                                                                                                                               
18:53         -- │ Notice(tapirigram): magnifier icon                                                                                                                                                                          
18:53         -- │ Notice(tapirigram): hamburger icon                                                                                                                                                                          
18:53         -- │ Notice(tapirigram): close icon                                                                                                                                                                              
18:53         -- │ Notice(tapirigram): up icon                                                                                                                                                                                 
18:53         -- │ Notice(tapirigram): up icon                                                                                                                                                                                 
18:53         -- │ Notice(tapirigram): up icon                                                                                                                                                                                 
18:53         -- │ Notice(tapirigram): twitter icon                                                                                                                                                                            
18:53         -- │ Notice(tapirigram): facebook icon

netsplit is not handled correctly

the irc transport does not reconnect if there is a netsplit on the server, thus rendering the transport basically useless. investigating the log provides the type of message

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.