Coder Social home page Coder Social logo

mrnodebot's Introduction

Mr. NodeBot

An IronY / FSociety Production

Build Status Dependencies devDependencies Status Known Vulnerabilities

Snyk Intergration

Since this is an IRC bot, and one cannot predict the type of character the bot may encounter in the wild, this project makes use of the Snyk vulnerabilitie patching system. You should regularly check the snyk patching system by running npm run snyk-protect.

Special Considerations

The bot currently depends on NickServ services supporting the ACC command for certain command authentication types. Networks confirmed to work include

  • freenode
  • DALnet

Dependencies

  • A Database engine, either MySql, MariaDB, Postgres, Sqlite3
  • node-gyp (python 2, and some sort of c build tools such as gcc or visual studio)

Install Steps

  • Install Node Modules npm install
  • Create a configuration file from a template cp config.sample.js config.js
  • Edit the configuration file
  • Configure a database
    • By default, the bot will use SQLite 3, npm install sqlite3
    • If using MySQL, npm install mysql2 (Knex supports both the node-mysql and node-mysql2 flavours, with the second being faster and more secure)
      • Create a Schema and be sure to give it a utf8mb4_unicode_ci character set (CREATE DATABASE db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci)
      • Modify the config.js accordingly
      • Once properly configured and run for the first time, the Bot will provision the database schema using migrations
  • Start the bot node index.js [--config config.js-path] or npm start

Keep the Bot Running

Included in the root directory is a sample systemd script (misc/mrnodebot.service), you can do it this way or use forever or any other node task runner. If you want to be able to use commands like update, restart, and halt while having the Bot come back it is important you take this into consideration.

Features

  • Logging / Analytics
  • SED Corrections
  • URL Announce
  • Popularity (upvote/downvote) system
  • Mention system
  • A Seen/Last-seen command to track usage
  • API Endpoints connected to Analytics
  • Express/Pug Web Front end
  • SocketIO connected to Express to deliver real time notifictions and bi-directional communication with the client

Debugging

You will find various debugging flags inside the config file. These will granually conroll file based debugging options. This framework does take advantage of SocketIO and express, which both utilize the Debug module. If you would like to see very intricate debugging for both express and socketIO, start the bot with the following command DEBUG=* node index.js.

Unit Testing

Unit testing is being introduced and has a long way to go to catch up. To run available tests npm test

Documentation

I am currently in the processes of providing jsdoc style docblocks for documentation generation. You can generate the documentation by running npm run generate-docs

Technologies

API Keys

  • Firebase API Key - The preferred URL shortner requires this (google is deprecating their other service), if not it will fall back to another option
  • Google API Key - For most features a Google API key with SafeSearch service, and YouTube search service enabled is required, however, if one is not provided, the bot will try to gracefully fall back onto is.gd
  • Imgur API Key - A Imgur API key is required to extract meta data on Imgur links in the URL announcer
  • Twitter API Key A Twitter API key is required to be able to send tweets, subscribe to tweets, or have a tweet sent out during the announce process
  • Bitly API Key A Bitly API key assists the amount of url shortners you have available to you
  • OMDB API Key Used in the imdb command and in the link matcher to pull info for imdb links

URL Shortner service

The Url shortner service, found in scripts/libs/_getShortService will provide a url shortner based on your API key availability. const shortService = require('../lib/_getShortService')(DOMAIN?)

  • DOMAIN is optional, but useful for things like avoiding googles blocking of certain domains.
  • If a firebase api key and url short domain is provided, the Firebase API will be used to shorten
  • After Firebase, if a Bitly API key is provided, Bitly will be used to shorten
  • If neither API key is available, isGd will be used to shorten (no key required, but certain pitfalls attached)

HTTP Codes

When dealing with the API, you will find a code property on most errors.

  • 501 Token not provided
  • 503 Token is invalid

Command Access Levels

  • owner - The Command can only be run by the bot owner (hard coded username/host combo in config.js)
  • admin - The Command can be run by the owner or anyone in the admin list
  • identified - The Command can be run by anyone using a nick identified with services
  • guest - The Command can be run by anyone
  • channelOp - The Command can be run by the owner, or anyone with ops in the channel it is being originated from
  • channelOpIdentified - the Command can be run by the owner, the admins, or anyone with ops in the channel who are also identified
  • channelVoice - the Command can be run by the owner, the the ops, and the voices in the channel it is originated from
  • channelVoiceIdentified - the Command can be run by identified voices, ops in the channel originated from, or owner and admins

Magic Functions

If a script exports the following functions, they will be run at the respective run level

  • onLoad Runs on initial load, and reload
  • unUnload Runs during reload prior to the destruction of the require / loadedScripts cache

Knex Migrations

This project is powered by knexjs and takes advantage of its migration system. In order to use migrations npm install -g knex and use the knex command, e.g. knex migrate:make add_users_table . More instructions can be found here. The bot will check for and install new migrations on startup.

Have questions? Looking to chat? Join us on #fsociety on irc.freenode.net

Pull Requests Welcome

Suggested Utils

  • Yarn - Fast, Reliable, and secure Dep Management
  • Node Publish - A better NPM Publish

mrnodebot's People

Contributors

davericher avatar dependabot-preview[bot] avatar dependabot[bot] avatar foxboron avatar itzdarc avatar jeek avatar mark-y avatar snyk-bot 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

Watchers

 avatar  avatar  avatar  avatar  avatar

mrnodebot's Issues

Pasted URL error

In channel https://www.amazon.com/gp/product/B01M20VBU7/ is pasted.
No output from bot. This happens rarely.
Debug console shows:
knex:query insert into logging (from, host, ident, text, timestamp, to) values (?, ?, ?, ?, ?, ?) undefined +4m
knex:bindings [ 'MillerBOSS',
knex:bindings 'cyber.cyber.cyber.cyber.cyber.cyber.cyber.millerboss.com',
knex:bindings '~shit',
knex:bindings 'https://www.amazon.com/gp/product/B01M20VBU7/',
knex:bindings 2018-05-12T05:09:11.493Z,
knex:bindings '#boats2' ] undefined +4m
knex:client releasing connection to pool: __knexUid48 +4ms
2018-05-12T05:09:11.605Z - warn: Error in URL Listener chain
{ err: '405 - ""',
stack: 'StatusCodeError: 405 - ""\n at new StatusCodeError (/root/MrNodeBot/node_modules/request-promise-core/lib/errors.js:32:15)\n at /root/MrNodeBot/node_modules/request-promise-core/lib/plumbing.js:97:41\n at \n at process._tickCallback (internal/process/next_tick.js:188:7)' }

Found a bug

10:53:24 AM M MrNodeBot: definition iff
10:53:26 AM ⇐ @MrNodeBot quit (~MrNodeBot@unaffiliated/irony/bot/mrnodebot) Quit: Something has gone seriously wrong, hopefully I will return!
10:53:33 AM M Found a bug
10:53:43 AM → @MrNodeBot (opped) joined

Feature request - YouTube search

Something along these lines
nick: `yt is it friday
bot: (nick) Rebecca Black - Friday - length 3m 48s - 808,685 likes, 3,156,561 dislikes (20.4%) - 120,501,511 views - rebecca on 2011.09.17 - http://youtu.be/kfVsfOSbJY0

Could be yt, or youtube for multiple commands for a youtube search.

MrNodeBot not handling restricted content properly

MrNodeBot doesn't properly manage youtube links that have a content warning for offensive or disturbing content, for example the video for the Nazi Germany National Anthem.

Expected behavior: MrNodeBot creates a shortened link, and adds it to the watch tv portal

Actual behavior: no output on IRC, no queued video on the tv portal.

Probable reason: bot isn't handling the content filter warning.

seen and first-seen issues

In channel
10:14:02 PM Jack `seen Amy
10:14:03 PM +layer-eight I need someone to look for Jack

10:14:07 PM Jack `seen Amy Amy
10:14:08 PM +layer-eight Seen →  Amy Saying tcl wtf for? via Log on #channel 3 hours ago

#channel only allows identified users so Jack is identified with NickServ.
10:19:59 PM -NickServ- Jack ACC 3 
https://github.com/funsocietyirc/MrNodeBot/blob/master/config.sample.js#L152 is set to 3

Jack can do the command as an OP or regular user and have the same issue. Jack is also an admin of the bot.
If the owner, me, runs `seen Amy it works fine in #channel and I can be either regular user, voice, or OP.

The same issue persists if `first-seen is ran, but

If `first-seen MillerBoss is done:

06:49:41 PM MillerBOSS `first-seen MillerBoss
06:49:41 PM layer-eight Seen →  MillerBOSS Saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago → additional results have been messaged to you MillerBOSS
Then the bot messaging me non-stop with:
06:49:42 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:43 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:43 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:43 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:44 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:45 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:45 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:46 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:46 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:47 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:47 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:47 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:47 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
06:49:47 PM layer-eight Then saying Layer-9 update via Log on #boats2 21 days ago → Changing their nick to MillerBoss on [#boats2] 13 days ago
Then I need to CTRL + C in the terminal window and the quit message of the bot is excess flood.

Turn down audio to see log https://millerboss.com/x/Screen-Recording-2018-05-10-01-08-13-D1.mp4
I was jamming to Dice while recording.

Here is git diff. MrNodeBot is in /root/MrNodeBot This is more or less a test instance.
https://gist.github.com/MillerBoss/2401ce9552d72ce4b9e0d0e12095e8a6

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.