GithubHelp home page GithubHelp logo

bytebot's People

Contributors

hipposen avatar izzy avatar jurkov avatar kaback avatar mape2k avatar mkzero avatar ohnenik avatar passwort11 avatar petrk94 avatar suicider avatar

Stargazers

 avatar  avatar  avatar

Watchers

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

bytebot's Issues

Add support for multiple url shorteners

The URL shorturl plugin should be configurable to use other shortener functions.

The following changes need to be made:

  • Additional section in the Bytebot configuration file
  • Dynamic loading in the plugin with a fallback to a default

Add excess flood protection to URL shortener

If the title of the HTML page is too long, the bot sends multiple messages in rapid succession. This could lead to a kick for excessive flooding.

Title-length should be limited to a sensible length, like 60-70 characters.

Dates plugin not working with timezone correctly

When trying to get dates with the following configuration:

'dates': {
'url': 'http://www.google.com/calendar/ical/2eskb61g20prl65k2qd01uktis%40group.calendar.google.com/public/basic.ics',
},

It throws an exception for the date/timezone implementation:

Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 525, in __bootstrap
self.__bootstrap_inner()
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 505, in run
self.__target(_self.__args, *_self.__kwargs)
--- ---
File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-> x86_64.egg/twisted/python/threadpool.py", line 191, in _worker
result = context.call(ctx, function, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux- x86_64.egg/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, _args, *_kw)
File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 81, in callWithContext
return func(args,*kw)
File "/home/bytespeicher/Bytebot/plugins/dates.py", line 66, in onPrivmsg
dt_local = dt_utc.astimezone(timezoneEF)
exceptions.AttributeError: 'datetime.date' object has no attribute 'astimezone'

Bot can't connect to IRC without SSL

Config: BYTEBOT_SSL = False
Error-Message:
Traceback (most recent call last):
File "./bytebot.py", line 192, in
reactor.connectSSL(BYTEBOT_SERVER, int(BYTEBOT_PORT), f)
TypeError: connectSSL() takes at least 5 arguments (4 given)

Create deamon scripts

The Bytebot should be started and daemonized via system daemon scripts. That should at least be SysV init shell script and - for future safety - a systemd unit file.

Add a key owner check

In a future Bytestatus system a key owner data base may be implemented. The bot can check the data base with the !key trigger and tell the channel who owns the Bytespeicher keys at the moment.

Exception in recurrence dates

plugin "dates" report the following:

2015-11-16 15:34:51+0100 [-] Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/_threads/_threadworker.py", line 46, in work
    task()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/_threads/_team.py", line 190, in doWork
    task()
--- <exception caught here> ---
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 241, in inContext
    result = inContext.theWork()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 257, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "/home/bytebot/Bytebot/plugins/dates.py", line 126, in onPrivmsg
    for e in rset.between(now, then):
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/dateutil/rrule.py", line 234, in between
    for i in gen:
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/dateutil/rrule.py", line 1144, in _iter
    self._genitem(rlist, gen)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/dateutil/rrule.py", line 1082, in __init__
    self.dt = advance_iterator(gen)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/dateutil/rrule.py", line 652, in _iter
    if until and res > until:
exceptions.TypeError: can't compare offset-naive and offset-aware datetimes

dates in wrong order

The iCal parser plugin dates.py reads the dates from a Google iCal but prints out the dates in chronological wrong order.

Implement a BRB command

There should be a plugin that allows to set a secondary space status to "be right back".

Those updates SHOULD then be distributed to the space status JSON. That way the status page, the Twitter status bot and the IRC topic plugin can react to this change and set their messages appropriately.

I propose to set the command to "!brb". This MUST NOT be set by anyone outside the space.

As the knowledge of which user is inside the space is a prerequisite issue #11 MUST be implemented first.

Before any implementation can take place there MUST be a way to set and retrieve a secondary status from the status JSON as well.

Implement a Godwin-Counter

A Godwin-Counter should be implemented. Functionalities should include counting the occurences of "Hitler" and synonyms.

A per-channel or per-user statistic is open for discussion.

The counter should be stored in permanent or semi-permanent location.

Add replace command

If a user corrects a message with 's/text/newtext/' this regex should be applied to the last message from this user.

Update the logging of Bytebot

The Bytebot config should enable one to change the logging output to a syslog server instead of stdout.

Also a debug level needs to be implemented.

Google URL shortener requires API keys now

Without an API key the goo.gl shortener will return the following error message when trying to shorten any URL:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}

The configuration needs an additional option for the API key and the key should be used when sending requests to Google. More information on how to retrieve the key and use it: https://developers.google.com/url-shortener/v1/getting_started

Ignore empty RSS feeds

When a server is unreacheable or returns an empty result or error page, the RSS plugin should ignore that feed and try to fetch it later.

Currently, it fetches the feed and saves the empty result. This will lead to a long list of changes send to the channel when the feed is available again.

Bot will be kicked if a plugin sends too many messages at once

If the bot is started the first time with e.g. the RSS reader plugin configured, it will be kicked for excess flooding as it tries to send all messages at once without any rate-limit. Messages from the bot should always be rate-limited. If a plugin tries to send too many messages at once this should trigger a warning and drop any messages above a certain message count.

Create an install/update script

The bot should have an install and/or update script to help set up the bot. Ideally this would be an ncurses menu or something similar.

This script should help with the configuration of standard variables and plugins.

This also means, we need an easy way to define configuration variables for the bot and all plugins.

Add a size check to the url shortener

When a user sends a URL of a big file the plugin will try to download the whole file. This is not necessary as plain files don't have HTML Header tags to check for.

To mitigate this problem there SHOULD be a configurable size limit and a whitelist of content types that will be parsed for title tags.

Use hostmasks for autoop

The autoop plugin should use hostmasks or allow usernames for specific(registered) users and hostmasks for other ops instead of only usernames.

Connection loss with exception

Bot leaves IRC Channel after the following Errors:

2015-11-17 18:32:21+0100 [-] Unhandled error in Deferred:
2015-11-17 18:32:21+0100 [-] Unhandled Error
Traceback (most recent call last):
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1194, in run
    self.mainLoop()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1203, in mainLoop
    self.runUntilCurrent()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/base.py", line 825, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/task.py", line 213, in __call__
    d = defer.maybeDeferred(self.f, *self.a, **self.kw)
--- <exception caught here> ---
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 1148, in _sendHeartbeat
    self.sendLine('PING ' + self.hostname)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 1117, in sendLine
    self._reallySendLine(line)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 1113, in _reallySendLine
    return basic.LineReceiver.sendLine(self, lowQuote(line) + '\r')
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/protocols/basic.py", line 635, in sendLine
    return self.transport.write(line + self.delimiter)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 530, in write
    self._write(bytes)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 573, in _write
    self._flushSendBIO()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 343, in _flushSendBIO
    self.transport.write(bytes)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/_newtls.py", line 191, in write
    FileDescriptor.write(self, bytes)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/abstract.py", line 355, in write
    self.startWriting()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/abstract.py", line 442, in startWriting
    self.reactor.addWriter(self)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/epollreactor.py", line 288, in addWriter
    EPOLLOUT, EPOLLIN)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/epollreactor.py", line 255, in _add
    self._poller.modify(fd, flags)
exceptions.IOError: [Errno 2] No such file or directory

2015-11-17 18:32:21+0100 [ByteBot (TLSMemoryBIOProtocol),client] Unhandled Error
Traceback (most recent call last):
  File "/home/bytebot/Bytebot/bytebot.py", line 196, in <module>
    reactor.run()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1194, in run
    self.mainLoop()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1206, in mainLoop
    self.doIteration(t)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/epollreactor.py", line 396, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event)
--- <exception caught here> ---
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 610, in _doReadOrWrite
    self._disconnectSelectable(selectable, why, inRead)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 255, in _disconnectSelectable
    selectable.connectionLost(f)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 479, in connectionLost
    self._commonConnection.connectionLost(self, reason)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 293, in connectionLost
    protocol.connectionLost(reason)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/protocols/tls.py", line 477, in connectionLost
    ProtocolWrapper.connectionLost(self, reason)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/protocols/policies.py", line 125, in connectionLost
    self.wrappedProtocol.connectionLost(reason)
  File "/home/bytebot/Bytebot/bytebot.py", line 37, in connectionLost
    irc.IRCClient.connectionLost(self, reason)
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 1134, in connectionLost
    self.stopHeartbeat()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/words/protocols/irc.py", line 1159, in stopHeartbeat
    self._heartbeat.stop()
  File "/home/bytebot/Bytebot/env/local/lib/python2.7/site-packages/twisted/internet/task.py", line 176, in stop
    assert self.running, ("Tried to stop a LoopingCall that was "
exceptions.AssertionError: Tried to stop a LoopingCall that was not running.

UTF-8 encoding for all output

Output using encode('ascii') should replace this with encode('utf-8'), so unicode characters are displayed properly.

Shorten links

If a user posts a message with a link a shortened link along with the content of the HTML title tag of that page(if available) should be posted.

The Bytebot needs a cleaner coding style (open for comments)

The current Bytebot code base is a mess when looking at consistency of code style. This is a problem, when new developers want to contribute or developers are looking for bugs in code they did not write.

To fight this, a code style guide should be created, that looks at the current code base and general Python code style best practices like PEP 8. This especially means checking line length, function and variable naming, a proper doc-block style, ...

Looking at PEP 8 and Twisted's naming conventions, these are clearly not compatible - Twisted uses camel-case-style naming, while PEP 8 will tell you to use names with underscores for better readability. So we could either abide to Twisted's camel case or mix camel case and underscore naming.

Breaking style compatibility with twisted has advantages and disadvantages. Mainly, PEP 8 itself states, that consistency is key to readability, so mixing style could have an impact on readability. But mixing the Twisted function naming with PEP 8 naming would make distinguishing Twisted and Bytebot functions easier.

So my proposal would be:

For the general code base, a clear style(with consideration for PEP-8 should be adopted:

Source encoding:

  • UTF-8
  • every source file has a single line comment for encoding declaration at the top

Indentation:

  • 4 spaces indent
  • continuation lines:
    • aligned vertically to the delimiter or
    • with hanging indent and no arguments on the first line

Line length and line breaks:

  • maximum line-length of 79 characters
  • maximum line-length of 72 characters inside doc blocks / comments
  • line breaks must use Python's implied line continuation inside parentheses, brackets and braces if possible
  • if not possible, a backslash may be used
  • top level functions and classes are surrounded by two blank lines
  • method declarations and class variables are surrounded by a single blank line
  • logical separation with a single blank line may be used
  • a semicolon must not occur to mark the end of a line
  • multiple statements must not occur on the same line

Whitespaces:

  • whitespaces must not occur:
    • at the end of lines or on blank lines
    • before a comma, semicolon or colon
    • immediately inside parentheses, brackets or braces
    • immediately befor the parentheses that start an argument list for a function call or indexing/slicing
    • around the assignment-operator for keywords or parameters
  • single whitespaces must occur:
    • around binary operators
      • assignment ( = )
      • augmented assignment ( +=, -=, /=, *= )
      • comparison ( == , < , > , != , <> , <= , >= , in , not in , is , is not )
      • boolean ( and , or , not )
      • after a colon inside lambdas, list comprehension

Imports:

  • imports must be at the top of the file
  • separate imports must be on separate lines
  • imports from the same module may be on a single line
  • imports must be grouped by:
    • standard Python library
    • third-party libraries
    • Bytebot libraries
  • imports must not use explicit relative import declarations
  • imports must not use an asterisk import declaration (i.e. from mod import *)

Quotes and comments:

  • double quotes for all string literals
  • triple quotes for comments and doc blocks
  • comments must be full sentences
  • inline comments must not be used
  • doc strings are PEP 257

Naming:

  • all identifiers must be in English
  • configuration variables are all capitalized with underscores
  • constants are all capitalized with underscores
  • variables are all lowercase with underscores
  • classes are capitalized words with no underscores
  • the letters of abbreviations in class names are all capitialized
  • Exception names are treated as class names
  • plugin classes are all lowercase with no underscores
  • module names are all lowercase and may contain underscores
  • functions and class methods are all lowercase with underscores
  • class methods inherited by the Twisted API are mixed case(commonly refered to as "camel case")
  • weak internal functions of classes are prefixed with an underscore
  • class properties and methods not to be accessed externally must be prefixed with two underscores
  • when an identifier conflicts with a Python keyword, a synonym must be used
  • instance methods must use self as the first keyword
  • class methods must use cls as the first keyword

Handle network timeouts

Catch twisted.internet.error.TimeoutError and restart connection instead of letting the bot commit suicide.

Exception when clientConnectionFailed

Traceback (most recent call last):
  File "/home/bytespeicher/Bytebot/bytebot.py", line 197, in <module>
    reactor.run()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/base.py", line 1192, in run
    self.mainLoop()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/base.py", line 1204, in mainLoop
    self.doIteration(t)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/epollreactor.py", line 396, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 88, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/python/log.py", line 73, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/posixbase.py", line 627, in _doReadOrWrite
    self._disconnectSelectable(selectable, why, inRead)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/posixbase.py", line 263, in _disconnectSelectable
    selectable.connectionLost(failure.Failure(why))
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 483, in connectionLost
    self.failIfNotConnected(error.ConnectError(string=reason))
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/tcp.py", line 460, in failIfNotConnected
    self.connector.connectionFailed(failure.Failure(err))
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/internet/base.py", line 1077, in connectionFailed
    self.factory.clientConnectionFailed(self, reason)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-13.2.0-py2.7-linux-x86_64.egg/twisted/protocols/policies.py", line 163, in clientConnectionFailed
    self.wrappedFactory.clientConnectionFailed(connector, reason)
  File "/home/bytespeicher/Bytebot/bytebot.py", line 171, in clientConnectionFailed
    log("FATAL: connection failed: %s" % reason, level=LOG_ERROR)
exceptions.TypeError: 'module' object is not callable

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.