Code Monkey home page Code Monkey logo

ukhasnet-bot's Introduction

IRC bot for UKHASnet Project

This is an IRC Bot written in C++ aimed at being useful and easily extendable for the #ukhasnet irc channel on freenode.

It is requested that you contact the author of the code if you find the code useful.

Class List

UKHASnet Namespace

This is the parent namespace for all classes used in this code.

Config Class

Reads in the configuration from config.json (see template for current format).

Future extensions will all the config to be modified whilst running and save that config back out.

Handler Class

Thread started from the main processes. Each process also connects to the Handler to pass it messages Handler() should only be called once and can be used to start the thread. Handler(irc::connection*) should be called by each connection thread to send messages to the handler

Planned commands PRIVMSG/NOTICE are all logged (!h will add a hidden flag on the DB version Also log other things (JOIN/PART/NICK/QUIT/MODE) ?

!seen When was a nickname last seen !node Provides info about a node !follow

Ideally in Future it should be possible to add the actual handlers to this class programatically

Logger

Handles logging to log files.

main

Not a class as such, but the main process for the bot.

UKHASnet::irc namespace

This namespace handles all the IRC specific parts

Connection Class

Handles connection to server Creates a thread per server to handle communications

Message Class

Used to store mesasges to and from the server

Server Class

Used to store details about a server

Work In Progress

irc::Channel Class

Will be used in the irc::Server class to store channel information (this is currently done with strings)

irc::Member Class

Will be used by the irc::Channel class to store who's in (or has been in) a channel (needed for the !seen function)

Database Class ??

Handles connection to DB

Classes for Handlers (seen,follow,nodes)

Ideally functions will be stored in their own classes allowing for easy extension of the code.

Ubuntu Installation

sudo apt-get install g++ sudo apt-get install make sudo apt-get install libjansson-dev sudo apt-get install libpqxx3-dev libpqxx-3.1

Note that this requires at least Jansson 2.3 (Ubuntu 12.04 has Jansson 2.2)

ukhasnet-bot's People

Contributors

m1ari avatar

Watchers

 avatar

ukhasnet-bot's Issues

Periodic cleanup of open logs

currently logs are open closed when we want to log something and we determine the day has changed. This may not be too bad with the server connection logs as there will be regular traffic (ping/pong etc). But for channel/person logs these could hang around for a while - this also means we don't get a useful === close log ==== message until something actively causes the logs to close.

Simple fix would be to have the Handler process detect day changes and go through all log handles calling close on them (requires a new method in the Logger class)

log folder not created on first run

On the first run the log folder isn't created by the server process (only when the handler is called). This leads to lots of errors from the server process not being able to write it's logs

Add !seen <nick> functionality

Requires adding in irc::Channel and irc::Member classes as well as tracking of joins/parts . Then add code in to the handler to get the seen timestamp and provide suitable messages (some of which may already be in place).

Connect to DB for storage

Will allow a live webbased logviewer (similar to logtail)
Means we can store seen data in the DB rather than periodic dumping to json

irc::message.getDest() shows the destination for what was recieved not who to reply to.

Whilst for messages to the channel getDest returns the right thing if the message was from a PRIVMSG or NOTICE it points back to ourself not to where we should reply to.

Simple fix might be to add a replyTo() method that uses similar logic to the logging code in the handler code.

related to this it might be worth adding a reply() method to the message class that can use this code and make the choice of NOTICE/PRIVMSG

add !tell <NICK> <MSG>

From 27/5/2014

14:01 < craag> A !tell command that leaves a message for someone, that's then repeated to them by the bot next time they join is useful
14:02 < craag> eg !tell jcoxon Haven't seen you in a while!
14:02 < craag> Then it'll tell him that next time he logs in

Logged ACTION messages need to strip the \001 at the end

From 23/05/2014

11:32 < tjanos> by the way: it seems, not all log files have the same format. My browser dont want to process for ex. this
file 23ukhasnet-2014-05-22.log as a poor text, it said it is binary file
11:35 < tjanos> The broser put the file in the gedit editor, it seems, it is readable, but I see only thios line with a
non-ascii char:
11:36 < tjanos> [10:51:25.787] * mfa298 is obviously failing at typing todayA [] at the and of this line
11:36 -!- flok420 [~folkert@2001:888:13b3:64:5054:ff:fe87:b394] has quit [Read error: Connection reset by peer]
11:38 < mfa298> the text logs are mostly just there for testing the bot so there might be some issues.
11:39 -!- ibanezmatt13 [~[email protected]] has quit [Quit: TV]
11:39 < mfa298> there's plenty of bug and TODO's in the code where I know there's work to do but it's good enough for most
things.
11:40 < tjanos> it seems me, it is a hex 0x01 and 0x0A chars at the end of your line
11:40 < mfa298> There's a TODO in the source code about that!
11:40 < tjanos> this is another line with this ends: [14:28:38.695] * mfa298 still needs to watch the gps stuffA
11:41 < tjanos> [16:10:38.594] * ibanezmatt13 is now revising, shh ;)A
11:41 < tjanos> seems the lins, started with *
11:42 < tjanos> lines
11:42 < mfa298> It's known about! https://github.com/m1ari/UKHASnet-bot/blob/master/handler.cpp#L70
11:42 < tjanos> Ok, I need to learn a little more

Handle disconnects

If the bot get's disconnected it stays running but doesn't do anything. Should detect disconnects and attempt to re-join.

This will be fun to test!

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.