Giter VIP home page Giter VIP logo

ninjabot's People

Contributors

ackwell avatar auscompgeek avatar bmon avatar cyphar avatar dpepsilon avatar fourkbomb avatar gnustomp avatar icedingo avatar mause avatar peterarnott avatar spake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ninjabot's Issues

Uno - Colourblind mode

Add symbols/letters before the cards, to identify the colour of them.

For

  1. Colourblind people
  2. People using Colloquy

core: make plugins run in threads

The current system only runs Kronos commands in threads, while all of the other triggers run in the main thread. This needs to be fixed before we can implement DoS protection (as suggested in #56) or any other time-sensitive operation. Also, it will allow for better separation of different tasks and make ninjabot more modular from an execution standpoint as well as a design standpoint. We could include limits on plugin threads, making some plugins have a higher priority than others, dedicate CPUs to particular threads, etc.

New README

The README is seriously out of date. Should probably be upgraded to a .md (Markdown), and give some info on plugins and how to write them.

Ninjabot instance has no attribute 'message_queue'

While starting sometimes an exception is raised:

ninjabot-allmywut git:master ❯ python ninjabot.py                                                                  ✹ ✭
ninjabot starting up
ERROR DURING TASK EXECUTION Ninjabot instance has no attribute 'message_queue'
Writing storage to disk
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncore.py", line 411, in __getattr__
    retattr = getattr(self.socket, attr)
AttributeError: 'NoneType' object has no attribute 'message_queue'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nick/Python/ninjabot-allmywut/kronos.py", line 469, in threadedcall
    self.execute()
  File "/home/nick/Python/ninjabot-allmywut/kronos.py", line 314, in execute
    self.action(*self.args, **self.kw)
  File "ninjabot.py", line 229, in send_queue
    while not self.message_queue.empty():
  File "/usr/lib/python3.4/asyncore.py", line 414, in __getattr__
    %(self.__class__.__name__, attr))
AttributeError: Ninjabot instance has no attribute 'message_queue'

weather

Suggestions:

Here's a whole list of weather APIs (filtered to JSON format).

Uno - colourblind formatting

Maybe it's just me, but at the moment, it's hard to tell what cards you have with the colourblind mode turned on.

20:44 < Sugarloaf0> spake: Maybe it's just me, but, I found it difficult to tell what
cards I had at a glance. I was thinking instead of having something
like [r6][r8][y1][b2], you could have something like
R:[6][8], Y:[1], B:[2].

Marvin's modules

Suggestion dump of Marvin's modules

  • help
  • modhelp (possibly integrate with help)
  • say
  • stats
  • g (google)

regex: sanitise newlines

So... it seems I managed to do this:

auscompgeek | s/.*/\r\nJOIN 0/
SuchNCSSBot | auscompgeek meant to say: 
        <-- | SuchNCSSBot (~ninjabot@unaffiliated/auscompgeek/bot/aucgbot) has left

... and now I have to restart it. Oops.

A join trigger would help as well.

Hook command system.

Disconnect direct messages, add module API, hook modules.

Possibly add drop-down box for default command?

race condition crash when sending the queue

not entirely sure what's going on here, but it definitely looks like a race condition.

bot stdout:

PING :cameron.freenode.net
SENT: PONG cameron.freenode.net

Writing storage to disk
:gnustomp!gnustomp@unaffiliated/gnustomp PRIVMSG ##hypnotoad :https://forum.groklearning.com/t/py-malware-dont-test-it/7248
Starting new HTTPS connection (1): forum.groklearning.com
Starting new HTTPS connection (1): groklearning.com
Starting new HTTPS connection (1): forum.groklearning.com
Starting new HTTPS connection (1): groklearning.com
:gnustomp!gnustomp@unaffiliated/gnustomp PRIVMSG ##hypnotoad :.-.
:gnustomp!gnustomp@unaffiliated/gnustomp PRIVMSG ##hypnotoad :i disapprove
:PaperBag!~bucket@unaffiliated/forkbomb/bot/paperbag PRIVMSG ##hypnotoad :\u0ca0_\u0ca0
SENT: PRIVMSG ##hypnotoad :Title: Grok Learning

error: uncaptured python exception, closing channel <__main__.Ninjabot connected chat.freenode.net:6667 at 0x7fb48a518780> (<class 'IndexError'>:deque index out of range [/usr/lib/python3.4/asyncore.py|write|91] [/usr/lib/python3.4/asyncore.py|handle_write_event|461] [/usr/lib/python3.4/asynchat.py|handle_write|178] [/usr/lib/python3.4/asynchat.py|initiate_send|250])
Writing storage to disk

what we saw:

19:15:00  +gnustomp | https://forum.groklearning.com/t/py-malware-dont-test-it/7248
19:15:01  +gnustomp | .-.
19:15:03  +gnustomp | i disapprove
19:15:03   PaperBag | ಠ_ಠ
19:15:06    NCSSBot | Title: Grok Learning
19:15:06    NCSSBot | Title: Grok Learning
19:15:19  +gnustomp | i should just reply with while True: os.fork()
19:15:19        <-- | NCSSBot (~ninjabot@[redacted]) has quit (Remote host closed the connection)

regex: have a timeout for regex execution

In its current form, the regex plugin is susceptible to ReDoS (as demonstrated by me on @gnustomp's ninjabot instance). A timeout is needed for the execution of the user-provided regex.

It has been suggested that threading may be used to achieve this.

dice.py error

Traceback (most recent call last):
  File "ninjabot.py", line 367, in message_recieved
    self.on_incoming(msg)
  File "ninjabot.py", line 378, in on_incoming
    self.handle_command(msg)
  File "ninjabot.py", line 402, in handle_command
    self.triggers[command](msg)
  File "C:\Users\kyouko\Documents\Code\python\ninjabot\plugins\misc\dice.py", line 82, in trigger_dice
    self.bot.privmsg(msg.channel, '{:s}: {:r} (total {:d})'.format(msg.nick, numbers, sum(numbers)))
ValueError: Unknown format code 'r' for object of type 'str'

use sets instead of lists where apropos

We should use sets more, because performance and ease of use.

Just poking around the code a little bit, I notice Ninjabot.ignored and Ninjabot.admins are good candidates for sets.

Uno - persistent scoring system

Implement a system that keeps track of how many times each user has won the game, with a leaderboard that appears both on request with a command, and after each game. Persistence should probably be to a dotfile in the user's home folder, in the same location as .ncssbot_config.

Tests damnit

I'm going to start off by writing some for my Storage rewrite (#62) in any case.

unittest.mock is very helpful in any case, for database and external api interaction :)

^reload trigger

Should add functionality that allows the bot to reload all plugins (^reload) or a single plugin (^reload ) without the need of restarting

Message queue

Should throttle the bot to 1 message a second (or something, probably have a setting in the config file) to prevent channel flood.

linkinfo: race condition

During the processing of URLs, there is a race condition in which two requests are made to the server and information sent to the channel twice.
Related error:

ERROR DURING TASK EXECUTION deque index out of range
Traceback (most recent call last):
  File "/home/notackwell/ninjabot/kronos.py", line 469, in threadedcall
    self.execute()
  File "/home/notackwell/ninjabot/kronos.py", line 314, in execute
    self.action(*self.args, **self.kw)
  File "./ninjabot.py", line 232, in send_queue
    self.irc_send(message, now=True)
  File "./ninjabot.py", line 215, in irc_send
    self.push(message_bytes)
  File "/usr/lib/python3.4/asynchat.py", line 190, in push
    self.initiate_send()
  File "/usr/lib/python3.4/asynchat.py", line 250, in initiate_send
    del self.producer_fifo[0]
IndexError: deque index out of range

Investigate why the bot leaks memory

It appears as though ninjabot tends to leak memory over time. e.g. I just checked the resource usage on the server and it was using roughly 3 times the amount of RAM it uses when it starts up.

We should probably investigate this.

  • Is Python's garbage collector being crappy?
  • Is it a plugin?
  • Is it the storage? I don't see any memleaks in the storage API.
  • Is it kronos?
  • Is it our __magic__ shiz?
  • Could it be the magic import hackery?

Fix up networking code

Need to do some work on the networking code, get it working with multiple connections, etc.

Also should fix up the passing of context...

Uno - End of round stats

A suggestion is to have the bot output statistics of the round when it is over

Some examples of stats could be:

  1. Everyone's hands (not technically a stat, but meh)
  2. Average time taken to play hand
  3. Most skipped person or number players have been skipped
  4. Cards played or player who played the most cards

Create wiki

Probably a good idea to make a wiki, with more in-depth details on how to write plugins for the bot. Either that, or write lots of dockstrings, and use ReadTheDocs! or something to generate a gh_pages site.

Uno - nick change tracking

At the moment, if someone changes their nick mid-game, the game awaits actions from their old nick. Even worse is if a user changes their nick and leaves, which forces an admin to kick the now defunct nick. The proposal is to track nick changes in the plugin to eliminate this issue. Another idea is to add a method like on_nickchange as a standard plugin method in Main.py, enabling tracking of changes across all plugins.

Add (accurate) timer support

Currently plugins have to use a timer_ function to utilise cooldowns, etc. Considering that i've already got kronos.py set up, it would be possible to add a function to Controller that adds functions to kronos. Stuff like a proper cooldown for UNO, etc.

Global persistence system

Add a persistence system that plugins (like uno) can easily utilise for stats and other things that should survive many restarts.

Missing data in Messages

Would seem that in some cases (quite a few actually), the Message's "body" and "channel" are empty, as seen below:
Image - missing data

Uno - autodraw

To avoid the whole game hanging when an admin isn't around and a player is idling indefinitely, the plugin should automatically make users draw a card after a certain number of seconds of inactivity (maybe 90 seconds?) to avoid ruining everyone else's fun!

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.