From 7f381012d56f172f868c6a3bf9ed914fecd53112 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 5 Jun 2012 20:44:45 +1200 Subject: [PATCH 01/11] added a proper error message --- plugins/factoids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/factoids.py b/plugins/factoids.py index 0d33062..79dd07f 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -22,7 +22,7 @@ def python(data, args, input): data = data[4:].strip() req = http.get("http://eval.appspot.com/eval", statement=statement).splitlines() if len(req) == 0: - return "Unknown Error." + return "Failed to recieve response from remote Python API.." req[0] = re_lineends.split(req[0])[0] if not req[0] == 'Traceback (most recent call last):': result = req[0].decode('utf8', 'ignore') From 90af9c097932e533810beed93eb12300bc72cf5c Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 5 Jun 2012 17:09:19 -0700 Subject: [PATCH 02/11] made 8ball.py use data/, and refactored it slightly (unused imports) --- plugins/8ball.py | 46 ++++++++++---------------------- plugins/data/8ball_responses.txt | 26 ++++++++++++++++++ 2 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 plugins/data/8ball_responses.txt diff --git a/plugins/8ball.py b/plugins/8ball.py index 3d9385b..6aeea04 100755 --- a/plugins/8ball.py +++ b/plugins/8ball.py @@ -1,41 +1,23 @@ from util import hook import random -import re -r = "\x02\x0305" # red -g = "\x02\x0303" # green -y = "\x02" # yellow (not really) +color_codes = { + "": "\x02\x0305", + "": "\x02\x0303", + "": "\x02" +} -answers = [g + "As I see it, yes", - g + "It is certain", - g + "It is decidedly so", - g + "Most likely", - g + "Outlook good", - g + "Signs point to yes", - g + "One would be wise to think so", - g + "Naturally", - g + "Without a doubt", - g + "Yes", - g + "Yes, definitely", - g + "You may rely on it", - y + "Reply hazy, try again", - y + "Ask again later", - y + "Better not tell you now", - y + "Cannot predict now", - y + "Concentrate and ask again", - y + "You know the answer better than I", - y + "Maybe...", - r + "You're kidding, right?", - r + "Don't count on it", - r + "In your dreams", - r + "My reply is no", - r + "My sources say no", - r + "Outlook not so good", - r + "Very doubtful"] +with open("plugins/data/8ball_responses.txt") as f: + responses = [line.strip() for line in f.readlines() + if not line.startswith("//")] @hook.command('8ball') -def eightball(inp, me=None): +def eightball(input, me=None): "8ball -- The all knowing magic eight ball, " \ "in electronic form. Ask and it shall be answered!" - me("shakes the magic 8 ball... %s" % (random.choice(answers))) + + out = random.choice(responses) + for code in color_codes: + out = out.replace(code, color_codes[code]) + me("shakes the magic 8 ball... %s" % out) diff --git a/plugins/data/8ball_responses.txt b/plugins/data/8ball_responses.txt new file mode 100644 index 0000000..87c7d6b --- /dev/null +++ b/plugins/data/8ball_responses.txt @@ -0,0 +1,26 @@ +As I see it, yes +It is certain +It is decidedly so +Most likely +Outlook good +Signs point to yes +One would be wise to think so +Naturally +Without a doubt +Yes +Yes, definitely +You may rely on it +Reply hazy, try again +Ask again later +Better not tell you now +Cannot predict now +Concentrate and ask again +You know the answer better than I +Maybe... +You're kidding, right? +Don't count on it +In your dreams +My reply is no +My sources say no +Outlook not so good +Very doubtful From abc5d196bada59dc6a82a07f34bbbe0255d026ee Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 6 Jun 2012 15:45:02 +1200 Subject: [PATCH 03/11] Added some new Minecraft 1.3 items, Thanks Mufin! --- plugins/data/itemids.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/data/itemids.txt b/plugins/data/itemids.txt index d6e8f09..37e1f50 100755 --- a/plugins/data/itemids.txt +++ b/plugins/data/itemids.txt @@ -1,5 +1,5 @@ // obtained from -// edited by Lukeroge and _frozen +// edited by Lukeroge, _frozen, and MufinMcFlufin // Block id 1 Stone 2 Grass Block @@ -147,6 +147,13 @@ 122 Dragon Egg 123 Redstone Lamp 124 Lit Redstone Lamp +127 Cocoa +128 Sandstone Stairs +129 Emerald Ore +130 Ender Chest +131 Tripwire Hook +132 Tripwire +133 Block of Emerald // Items Ids 256 Iron Shovel 257 Iron Pickaxe @@ -338,7 +345,7 @@ 380 Cauldron 381 Eye of Ender 382 Glistering Melon -383 Spawn Egg +// 383 Spawn Egg 383:50 Creeper Egg 383:51 Skeleton Egg 383:52 Spider Egg @@ -362,6 +369,9 @@ 383:120 Villager Egg 384 Bottle Of Enchanting 385 Fire Charge +386 Book and Quill +387 Written Book +388 Emerald // Records 2256 Music Disc 13 2257 Music Disc Cat From d27185913f5216ffba62f186afb90396a066cef9 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 8 Jun 2012 10:58:42 +1200 Subject: [PATCH 04/11] Fixed up a namefile --- plugins/data/namefiles/items.nam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/data/namefiles/items.nam b/plugins/data/namefiles/items.nam index f7431c9..28b573a 100755 --- a/plugins/data/namefiles/items.nam +++ b/plugins/data/namefiles/items.nam @@ -45,7 +45,7 @@ Needle Pin Token Helm -Battleaxe +Battleaxe [mid] of [final] From ce53be53d28a27a45930b2ac36d67e130cd41f1a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Fri, 8 Jun 2012 11:42:30 +1200 Subject: [PATCH 05/11] Moved the colour code to only run when first loading the plugin --- plugins/8ball.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/8ball.py b/plugins/8ball.py index 6aeea04..59ddc35 100755 --- a/plugins/8ball.py +++ b/plugins/8ball.py @@ -8,6 +8,8 @@ color_codes = { } with open("plugins/data/8ball_responses.txt") as f: + for code in color_codes: + f = f.replace(code, color_codes[code]) responses = [line.strip() for line in f.readlines() if not line.startswith("//")] @@ -17,7 +19,6 @@ def eightball(input, me=None): "8ball -- The all knowing magic eight ball, " \ "in electronic form. Ask and it shall be answered!" - out = random.choice(responses) - for code in color_codes: - out = out.replace(code, color_codes[code]) - me("shakes the magic 8 ball... %s" % out) + # here we use voodoo magic to tell the future + magic = random.choice(responses) + me("shakes the magic 8 ball... %s" % magic) From face8fb5f258efce2a7fa69ddb8ef028bb10e609 Mon Sep 17 00:00:00 2001 From: Neer Sighted Date: Sat, 9 Jun 2012 12:19:16 -0700 Subject: [PATCH 06/11] Update develop --- README.md | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a416fe4..ef0eb5f 100755 --- a/README.md +++ b/README.md @@ -25,31 +25,28 @@ Unzip the resulting file, and continue to read this document. ## Install -Before you can run the bot, you need to install a few Python modules. These are `lXML` and `BeautifulSoup`. These can be installed with PIP (The Python package manager). If you use Windows and dont want to set up pip, you can also find `exe` installers on the internet: +Before you can run the bot, you need to install a few Python modules. These are `lXML`, `Enchant`, `urllib3`, and `BeautifulSoup`. These can be installed with `pip` (The Python package manager), or `easy_install` (A more basic version of `pip`): -`pip install lxml` +`[sudo] pip install lxml pyenchant urllib3 beautifulsoup` -`pip install beautifulsoup` +or +`[sudo] easy_install lxml pyenchant urllib3 beautifulsoup` -On Debian based systems, you can get pip with +### Installing `pip` -`apt-get install pip` +```shell +curl -O http://python-distribute.org/distribute_setup.py +python distribute_setup.py +easy_install pip +``` -For `.spell` to work, we also need a library called `Enchant`. On Debian based systems, install it with: +(If you use Windows and don't want to set up pip, you can also find `exe` installers on the internet.) -`apt-get install python-enchant` - -In addition, for `.whois` to work optimally, you must have `whois` installed. Again, on Debian based systems, install it with: - -`apt-get install whois` - -(*These commands may need to be prefixed with `sudo`*) - -If you are a user of another Linux disto, use your package manager to install the dependencies, or, for other operating systems, use **Google** to locate source packages you can install. +## Running Once you have installed the required dependencies, there are two ways you can run the bot: -### Using the launcher: +### Launcher The launcher will start the bot as a background process, and allow the bot to close and restart itself. This is only supported on unix-like machines (not Windows). @@ -69,7 +66,7 @@ It will generate a default config for you. Once you have edited the config, run This will start up your bot as a background process. To stop it, use `./cloudbot stop`. (Config docs at the [wiki](http://git.io/cloudbotircconfig)) -### Manually running the bot: +### Manually To manually run the bot and get debug output, run it with: From 96196adb726de492030b33eaf86ac828970e95e1 Mon Sep 17 00:00:00 2001 From: Neer Sighted Date: Sat, 9 Jun 2012 12:21:48 -0700 Subject: [PATCH 07/11] Update develop --- README.md | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index ef0eb5f..43ac7ee 100755 --- a/README.md +++ b/README.md @@ -17,13 +17,15 @@ CloudBot is a Python IRC bot very heavily based on [Skybot](http://git.io/skybot * Automatic reloading * Little boilerplate -## Download +## Getting and using CloudBot + +### Download Get CloudBot at [git.io/getcloudbotirc](http://git.io/getcloudbotirc "Get CloudBot from Github!"). Unzip the resulting file, and continue to read this document. -## Install +### Install Before you can run the bot, you need to install a few Python modules. These are `lXML`, `Enchant`, `urllib3`, and `BeautifulSoup`. These can be installed with `pip` (The Python package manager), or `easy_install` (A more basic version of `pip`): @@ -33,7 +35,7 @@ or `[sudo] easy_install lxml pyenchant urllib3 beautifulsoup` -### Installing `pip` +#### Install `pip` ```shell curl -O http://python-distribute.org/distribute_setup.py @@ -43,10 +45,11 @@ easy_install pip (If you use Windows and don't want to set up pip, you can also find `exe` installers on the internet.) -## Running +### Run Once you have installed the required dependencies, there are two ways you can run the bot: -### Launcher + +#### Launcher The launcher will start the bot as a background process, and allow the bot to close and restart itself. This is only supported on unix-like machines (not Windows). @@ -66,7 +69,7 @@ It will generate a default config for you. Once you have edited the config, run This will start up your bot as a background process. To stop it, use `./cloudbot stop`. (Config docs at the [wiki](http://git.io/cloudbotircconfig)) -### Manually +#### Manually To manually run the bot and get debug output, run it with: @@ -74,9 +77,11 @@ To manually run the bot and get debug output, run it with: On Windows you can usually just double-click the `bot.py` file to start the bot, as long as you have Python installed correctly. -(note that running it without the launcher will break the restart and stop commands) +(note: running the bot without the launcher breaks the start and restart commands) -## Documentation +## Getting help with CloudBot + +### Documentation To configure your CloudBot, visit the [Config Wiki Page](http://git.io/cloudbotircconfig). @@ -84,12 +89,22 @@ To write your own plugins, visit the [Plugin Wiki Page](http://git.io/cloudbotir More at the [Wiki Main Page](http://git.io/cloudbotircwiki). -## Support +### Support The developers reside in [#CloudBot](irc://irc.esper.net/cloudbot) on [EsperNet](http://esper.net) and would be glad to help you. If you think you have found a bug/have a idea/suggestion, please **open a issue** here on Github. +### Requirements + +CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* and **Ubuntu** *11.10* with **Python** *2.7.2*. + +It **requires Python modules** `lXML`, `BeautifulSoup` and `Enchant`, `psutil`, and `HTTPlib2`. + +The programs `daemon` or `screen` are recomended for the wrapper to run optimaly. + +**Windows** users: Windows compatibility with the wrapper and some plugins is **broken** (such as ping), but we do intend to add it.³ + ## Example CloudBots The developers of CloudBot run two CloudBots on [Espernet](http://esper.net). @@ -100,17 +115,8 @@ They can both be found in [#CloudBot](irc://irc.esper.net/cloudbot "Connect via **neerbot** is the unstable bot, and runs on the latest(ish) development version of CloudBot. (neerbot is running on **Debian** *Wheezy/Testing* with **Python** *2.7.2*) -## Requirements - -CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* and **Ubuntu** *11.10* with **Python** *2.7.2*. - -It **requires Python modules** `lXML`, `BeautifulSoup` and `Enchant`, `psutil`, and `HTTPlib2`. - -The programs `daemon` or `screen` are recomended for the wrapper to run optimaly. - -**Windows** users: Windows compatibility with the wrapper and some plugins is **broken** (such as ping), but we do intend to add it.³ - ## License + CloudBot is **licensed** under the **GPL v3** license. The terms are as follows. CloudBot/DEV From f1b080474e0a24dc8d00e634e79287ae7496a7f9 Mon Sep 17 00:00:00 2001 From: Neer Sighted Date: Sat, 9 Jun 2012 12:24:03 -0700 Subject: [PATCH 08/11] Update develop --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 43ac7ee..6daec00 100755 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Once you have installed the required dependencies, there are two ways you can ru The launcher will start the bot as a background process, and allow the bot to close and restart itself. This is only supported on unix-like machines (not Windows). -For the launcher to work properly, install `screen`, or `daemon` (daemon is recommended) : +For the launcher to work properly, install `screen`, or `daemon` (daemon is recommended): `apt-get install screen` @@ -97,9 +97,9 @@ If you think you have found a bug/have a idea/suggestion, please **open a issue* ### Requirements -CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* and **Ubuntu** *11.10* with **Python** *2.7.2*. +CloudBot runs on **Python** *2.7.x*. It is developed on **Ubuntu** *12.04* with **Python** *2.7.2+*. -It **requires Python modules** `lXML`, `BeautifulSoup` and `Enchant`, `psutil`, and `HTTPlib2`. +It **requires Python modules** `lXML`, `Enchant`, `urllib3`, and `BeautifulSoup`. The programs `daemon` or `screen` are recomended for the wrapper to run optimaly. From a47d99c0c22cc86c465165d48b864bf95af8cb1d Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 11 Jun 2012 10:21:44 +1200 Subject: [PATCH 09/11] Update develop --- plugins/password.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/plugins/password.py b/plugins/password.py index af17532..4a4396f 100755 --- a/plugins/password.py +++ b/plugins/password.py @@ -10,40 +10,35 @@ def gen_password(types): okay = [] #find the length needed for the password numb = types.split(" ") - - for x in numb[0]: - #if any errors are found defualt to 10 - if x not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: - numb[0] = 10 - length = int(numb[0]) + + try: + length = int(numb[0]) + except ValueError: + length = 10 + needs_def = 0 #alpha characters if "alpha" in types or "letter" in types: - for x in string.ascii_lowercase: - okay.append(x) + okay = okay + string.ascii_lowercase #adds capital characters if not told not to if "no caps" not in types: - for x in string.ascii_uppercase: - okay.append(x) + okay = okay + string.ascii_uppercase else: needs_def = 1 #adds numbers if "numeric" in types or "numbers" in types: - for x in range(0, 10): - okay.append(str(x)) + okay = okay + [str(x) for x in range(0, 10)] else: needs_def = 1 #adds symbols if "symbols" in types: sym = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', ']', '{', '}', '\\', '|', ';', ':', "'", '.', '>', ',', '<', '/', '?', '`', '~', '"'] - for x in sym: - okay.append(x) + okay = okay + sym else: needs_def = 1 #defaults to lowercase alpha password if no arguments are found if needs_def == 1: - for x in string.ascii_lowercase: - okay.append(x) + okay = okay + [str(x) for x in xrange(0, 10)] password = "" #generates password for x in range(length): From f2ec2eb8d390c382aa69edf325dd59f508d4839e Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 11 Jun 2012 10:24:30 +1200 Subject: [PATCH 10/11] derp --- plugins/password.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/password.py b/plugins/password.py index 4a4396f..d7aaea2 100755 --- a/plugins/password.py +++ b/plugins/password.py @@ -38,7 +38,7 @@ def gen_password(types): needs_def = 1 #defaults to lowercase alpha password if no arguments are found if needs_def == 1: - okay = okay + [str(x) for x in xrange(0, 10)] + okay = okay + string.ascii_lowercase password = "" #generates password for x in range(length): From 20b0e46a28ce08804c3ab90f624d7138e4282eeb Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 11 Jun 2012 10:36:29 +1200 Subject: [PATCH 11/11] Update develop --- plugins/password.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/plugins/password.py b/plugins/password.py index d7aaea2..537296a 100755 --- a/plugins/password.py +++ b/plugins/password.py @@ -5,42 +5,40 @@ import random def gen_password(types): - #Password Generator - The Noodle http://bowlofnoodles.net + # Password Generator - The Noodle http://bowlofnoodles.net okay = [] - #find the length needed for the password + # find the length needed for the password numb = types.split(" ") try: length = int(numb[0]) except ValueError: length = 10 - - needs_def = 0 - #alpha characters + + # add alpha characters if "alpha" in types or "letter" in types: okay = okay + string.ascii_lowercase #adds capital characters if not told not to if "no caps" not in types: okay = okay + string.ascii_uppercase - else: - needs_def = 1 - #adds numbers + + # add numbers if "numeric" in types or "numbers" in types: okay = okay + [str(x) for x in range(0, 10)] - else: - needs_def = 1 - #adds symbols + + # add symbols if "symbols" in types: sym = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', '_', '+', '[', ']', '{', '}', '\\', '|', ';', ':', "'", '.', '>', ',', '<', '/', '?', '`', '~', '"'] - okay = okay + sym - else: - needs_def = 1 - #defaults to lowercase alpha password if no arguments are found - if needs_def == 1: + okay += okay + sym + + # defaults to lowercase alpha password if the okay list is empty + if not okay: okay = okay + string.ascii_lowercase + password = "" - #generates password + + # generates password for x in range(length): password = password + random.choice(okay) return password