Browse Source

minor fixes, cleanup, and general improvements

tags/v0.1^2
Ben Kurtovic 13 years ago
parent
commit
3405845303
9 changed files with 32 additions and 24 deletions
  1. +2
    -2
      bot/commands/afc_report.py
  2. +6
    -1
      bot/commands/chanops.py
  3. +8
    -2
      bot/commands/crypt.py
  4. +9
    -12
      bot/commands/git.py
  5. +2
    -3
      bot/commands/help.py
  6. +1
    -1
      bot/commands/threads.py
  7. +2
    -1
      bot/frontend.py
  8. +1
    -1
      bot/main.py
  9. +1
    -1
      earwigbot.py

+ 2
- 2
bot/commands/afc_report.py View File

@@ -46,8 +46,8 @@ class Command(BaseCommand):
return return


url = page.url().replace("en.wikipedia.org/wiki", "enwp.org") url = page.url().replace("en.wikipedia.org/wiki", "enwp.org")
short = re.sub(r"wikipedia( talk)?:articles for creation/", "", title,
re.IGNORECASE)
short = re.sub("wikipedia( talk)?\:articles for creation\/", "", title,
flags=re.IGNORECASE)
status = self.get_status(page) status = self.get_status(page)
user = self.site.get_user(page.creator()) user = self.site.get_user(page.creator())
user_name = user.name() user_name = user.name()


+ 6
- 1
bot/commands/chanops.py View File

@@ -8,12 +8,17 @@ class Command(BaseCommand):
name = "chanops" name = "chanops"


def check(self, data): def check(self, data):
commands = ["voice", "devoice", "op", "deop"]
commands = ["chanops", "voice", "devoice", "op", "deop"]
if data.is_command and data.command in commands: if data.is_command and data.command in commands:
return True return True
return False return False


def process(self, data): def process(self, data):
if data.command == "chanops":
msg = "available commands are !voice, !devoice, !op, and !deop."
self.connection.reply(data, msg)
return

if data.host not in config.irc["permissions"]["admins"]: if data.host not in config.irc["permissions"]["admins"]:
msg = "you must be a bot admin to use this command." msg = "you must be a bot admin to use this command."
self.connection.reply(data, msg) self.connection.reply(data, msg)


+ 8
- 2
bot/commands/crypt.py View File

@@ -8,14 +8,20 @@ import blowfish
class Command(BaseCommand): class Command(BaseCommand):
"""Provides hash functions with !hash (!hash list for supported algorithms) """Provides hash functions with !hash (!hash list for supported algorithms)
and blowfish encryption with !encrypt and !decrypt.""" and blowfish encryption with !encrypt and !decrypt."""
name = "cryptography"
name = "crypt"


def check(self, data): def check(self, data):
if data.is_command and data.command in ["hash", "encrypt", "decrypt"]:
commands = ["crypt", "hash", "encrypt", "decrypt"]
if data.is_command and data.command in commands:
return True return True
return False return False


def process(self, data): def process(self, data):
if data.command == "crypt":
msg = "available commands are !hash, !encrypt, and !decrypt."
self.connection.reply(data, msg)
return

if not data.args: if not data.args:
msg = "what do you want me to {0}?".format(data.command) msg = "what do you want me to {0}?".format(data.command)
self.connection.reply(data, msg) self.connection.reply(data, msg)


+ 9
- 12
bot/commands/git.py View File

@@ -8,8 +8,8 @@ from classes import BaseCommand
import config import config


class Command(BaseCommand): class Command(BaseCommand):
"""Commands to interface with the bot's git repository; use '!git help' for
a sub-command list."""
"""Commands to interface with the bot's git repository; use '!git' for a
sub-command list."""
name = "git" name = "git"


def process(self, data): def process(self, data):
@@ -20,8 +20,7 @@ class Command(BaseCommand):
return return


if not data.args: if not data.args:
msg = "no arguments provided. Maybe you wanted '!git help'?"
self.connection.reply(data, msg)
self.do_help()
return return


if data.args[0] == "help": if data.args[0] == "help":
@@ -59,7 +58,7 @@ class Command(BaseCommand):


def do_help(self): def do_help(self):
"""Display all commands.""" """Display all commands."""
help_dict = {
help = {
"branch": "get current branch", "branch": "get current branch",
"branches": "get all branches", "branches": "get all branches",
"checkout": "switch branches", "checkout": "switch branches",
@@ -67,13 +66,11 @@ class Command(BaseCommand):
"pull": "update everything from the remote server", "pull": "update everything from the remote server",
"status": "check if we are up-to-date", "status": "check if we are up-to-date",
} }
keys = help_dict.keys()
keys.sort()
help = ""
for key in keys:
help += "\x0303%s\x0301 (%s), " % (key, help_dict[key])
help = help[:-2] # trim last comma and space
self.connection.reply(self.data, "sub-commands are: %s." % help)
msg = ""
for key in sorted(help.keys()):
msg += "\x0303{0}\x0301 ({1}), ".format(key, help[key])
msg = msg[:-2] # Trim last comma and space
self.connection.reply(self.data, "sub-commands are: {0}.".format(msg))


def do_branch(self): def do_branch(self):
"""Get our current branch.""" """Get our current branch."""


+ 2
- 3
bot/commands/help.py View File

@@ -18,9 +18,8 @@ class Command(BaseCommand):


def do_main_help(self, data): def do_main_help(self, data):
"""Give the user a general help message with a list of all commands.""" """Give the user a general help message with a list of all commands."""
msg = "I am a bot! I have {0} commands loaded: {1}. You can get help for any command with '!help <command>'."
cmnds = self.cmnds.keys()
cmnds.sort()
msg = "Hi, I'm a bot! I have {0} commands loaded: {1}. You can get help for any command with '!help <command>'."
cmnds = sorted(self.cmnds.keys())
msg = msg.format(len(cmnds), ', '.join(cmnds)) msg = msg.format(len(cmnds), ', '.join(cmnds))
self.connection.reply(data, msg) self.connection.reply(data, msg)




+ 1
- 1
bot/commands/threads.py View File

@@ -20,7 +20,7 @@ class Command(BaseCommand):
def process(self, data): def process(self, data):
self.data = data self.data = data
if data.host not in config.irc["permissions"]["owners"]: if data.host not in config.irc["permissions"]["owners"]:
msg = "at this time, you must be a bot owner to use this command."
msg = "you must be a bot owner to use this command."
self.connection.reply(data, msg) self.connection.reply(data, msg)
return return




+ 2
- 1
bot/frontend.py View File

@@ -93,7 +93,8 @@ def _process_message(line):


# If we are pinged, pong back to the server: # If we are pinged, pong back to the server:
if line[0] == "PING": if line[0] == "PING":
connection.send("PONG %s" % line[1])
msg = " ".join(("PONG", line[1]))
connection.send(msg)


# On successful connection to the server: # On successful connection to the server:
if line[1] == "376": if line[1] == "376":


+ 1
- 1
bot/main.py View File

@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-


""" """


+ 1
- 1
earwigbot.py View File

@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-


""" """


Loading…
Cancel
Save