Преглед на файлове

minor fixes, cleanup, and general improvements

tags/v0.1^2
Ben Kurtovic преди 13 години
родител
ревизия
3405845303
променени са 9 файла, в които са добавени 32 реда и са изтрити 24 реда
  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 Целия файл

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

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)
user = self.site.get_user(page.creator())
user_name = user.name()


+ 6
- 1
bot/commands/chanops.py Целия файл

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

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

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"]:
msg = "you must be a bot admin to use this command."
self.connection.reply(data, msg)


+ 8
- 2
bot/commands/crypt.py Целия файл

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

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 False

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:
msg = "what do you want me to {0}?".format(data.command)
self.connection.reply(data, msg)


+ 9
- 12
bot/commands/git.py Целия файл

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

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"

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

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

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

def do_help(self):
"""Display all commands."""
help_dict = {
help = {
"branch": "get current branch",
"branches": "get all branches",
"checkout": "switch branches",
@@ -67,13 +66,11 @@ class Command(BaseCommand):
"pull": "update everything from the remote server",
"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):
"""Get our current branch."""


+ 2
- 3
bot/commands/help.py Целия файл

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

def do_main_help(self, data):
"""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))
self.connection.reply(data, msg)



+ 1
- 1
bot/commands/threads.py Целия файл

@@ -20,7 +20,7 @@ class Command(BaseCommand):
def process(self, data):
self.data = data
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)
return



+ 2
- 1
bot/frontend.py Целия файл

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

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

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


+ 1
- 1
bot/main.py Целия файл

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

"""


+ 1
- 1
earwigbot.py Целия файл

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

"""


Зареждане…
Отказ
Запис