Git Product home page Git Product logo

irc's Introduction

irc

tinkering with a made-from-scratch irc library in python

installing

install from github (recommended):

pip install -e git+git://github.com/coleifer/irc.git#egg=irckit

install using pypi:

pip install irckit

install dependencies:

pip install gevent (for botnet)
pip install httplib2 (for some of the bots)

example bot

from irc import IRCBot, run_bot


class GreeterBot(IRCBot):
    def greet(self, nick, message, channel):
        return 'Hi, %s' % nick

    def command_patterns(self):
        return (
            self.ping('^hello', self.greet),
        )


host = 'irc.freenode.net'
port = 6667
nick = 'greeterbot'

run_bot(GreeterBot, host, port, nick, ['#botwars'])

running the botnet

the botnet consists of a "boss" command program which interfaces with any number of "workers". to run it from the command-line:

python boss.py -c secretbotz -n daboss1

this will start the command program using "#secretbotz" as the command channel. the boss will be identified by the nickname "daboss1". the default host is irc.freenode.net but can be configured using the "-h" option.

next, start up any number of workers. the workers will need to know the nick of the command bot so they can register themselves and start accepting tasks:

python worker.py -b daboss1

now you should be able to join #secretbotz using your IRC client and see "daboss1" just chilling out:

<cleifer> !auth password
<daboss1> Success
<cleifer> !status
<daboss1> 1 workers available
<daboss1> 0 tasks have been scheduled

let's execute a program on the worker machine:

<cleifer> !execute run vmstat
<daboss1> Scheduled task: "run vmstat" with id 1 [1 workers]
<daboss1> Task 1 completed by 1 workers

what was the output of the command?

cleifer> !print
<daboss1> [w0rk3r:{alpha}] - run vmstat
<daboss1> procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
<daboss1> r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
<daboss1> 0  0      0 977784 504004 910144    0    0    46    29  103  443  3  1 96  0

irc's People

Contributors

coleifer avatar tmc avatar runeh avatar wraithan avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

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.