« first day    last day (483 days later) » 

6:18 AM
@ArtOfCode Google App Engine? I cannot help with that. But, if you want, I could host KarmaBot on my cloud when it's ready.
 
 
2 hours later…
8:22 AM
@ProgramFOX Ah, I assumed you used GAE to get 24-hour service. That'd be great if you would :)
 
Sure, I'll do host the bot then :)
 
8:36 AM
@ArtOfCode have you worked on it at all?
also will you release the code for KarmaBot?
(Not the code for your AI of course)
 
17 hours ago, by ArtOfCode
@ProgramFOX definitely will do as soon as I've made sense of the code and set it up and started something
 
@overactor If you scroll a long way up, you'll find that we spent yesterday trying to set up a copy of ProgramFOX's bot
 
A lot to read
good to know
 
I'll start writing extra commands in today
 
@ArtOfCode So are you forking @ProgramFOX's bot?
 
8:40 AM
As my bot's goals are entirely different than yours, just starting from scratch might be easier while you use my bot as example.
 
@ProgramFOX The idea is to fork your bot because it's a good implementation.
I'll just add extra commands
(also, because I'm lazy)
 
lol
 
Bot started.
bot
Commands: alive, help, listcommands, random, randomchoice, randomint, shuffle, translate, utc, xkcd, xkcdrandomnumber
 
Having fun with executing commands on the console? :P
 
yep
Tue Jun 30 08:46:54 2015
 
8:46 AM
Can KarmaBot talk already?
 
@ArtOfCode is the bot using your account for now?
 
@overactor indeed it is
 
@overactor yes it is
 
Makes sense
 
because trying to use KB's account is still throwing TypeErrors at me
 
8:47 AM
Still?
 
@ArtOfCode xkcd help
 
>>help xkcd
 
@ProgramFOX Shows the specified xkcd comic. Syntax: >>xkcd comic_id
 
@overactor ^
 
aha
 
8:48 AM
Moment, moving to the next lesson, so I'm shutting down temporarily
 
@ArtOfCode After more than 12 hours I believe it's worth trying again to run on KarmaBot.
 
Could these groups of commands not be made modular somehow?
 
You mean, writing an external file which the bot can read and use without having to change the main file?
 
@ProgramFOX You're always going to have to modify some file
could be some sort of manifest file
 
Well, you can write a command in some external file and then add it to the dictionary in the main file, if that's what you mean.
 
8:54 AM
I'm reading some more, I suppose it's not very difficult to add and remove functionality
 
it isn't, no
 
What I mean though is adding a bunch of commands in a file and then just pointing to that file in a manifest or the main file
 
You guys are doing half my work for me :)
 
All I'm doing is spouting ideas that will add more work
 
@overactor that's what can be done, kinda
you just have to add an import to the Chatbot.py file and add the command to the dictionary in Chatbot.py
 
8:57 AM
Bot started.
 
@ProgramFOX Yeah, but you have each individual command in the main file
Which is not too bad really, but could be improved a bit.
 
so you would add an option to load all commands from one file?
 
Well it's an easy architecture to add commands to :)
 
Maybe I'm not making sense but I'm thinking of something like this
in one file, you have class with a bunch of commands, implementations of those commands and hlop text for those commands as well as anything additional these commands might need.
The in the main file you do something like:
...
self.modules = {
    "owner": new OwnerModule(),
    "points": new PointsModule(),
    ...
}
...
 
The problem is that some of those commands require data from the Chatbot class, and then those commands have to be added to that class.
 
9:08 AM
@ProgramFOX move that data to a seperate file (or files) and import in the module files?
 
So... the Chatbot imports the modules, and the modules import the Chatbot?
ah wait no, I see
 
@ProgramFOX does the message sender get passed as an argument anywhere?
 
@ArtOfCode See the msg argument, it's somewhere in there.
@overactor That would defeat the purpose of having a Chatbot class which is there to avoid global or shared variables.
Anyway I'm aware that my bot needs a lot of refactoring :P
 
Bot started.
 
@ArtOfCode Try msg.owner.name
 
9:12 AM
>>points
 
@ProgramFOX I'm not critisizing, I couldn't have made it probably
 
Bot started.
 
I agree that something like modules would be useful, but it would probably require that refactoring.
Especially because my bot has special features for a specific room, which are mixed up with the standard features.
 
Bot started.
 
From what I can see, Chatbot.py needs to be taken apart and refactored and Commands and CommandHelp need to be chopped up to form the modules.
Does that seem right to you?
 
9:18 AM
Yes, it does.
 
OK msg has no attribute owner apparently. Looking at some other classes it appears it might be event.user.id... sound right?
Bot started.
OK no it's not xD
 
dammit I cannot use my own bot anymore
 
Hmm, do I feel up for refactoring a chatbot?
 
uhh... let's check what's actually in msg because I believe I forgot that :P
There has to be an owner attribute there @ArtOfCode...
But it's a bit hard to verify because it appears I never use the msg parameter.
@ArtOfCode Try event.user.name, that should work.
 
ta
Bot started.
NoneType object has no attribute user.
 
9:26 AM
@ProgramFOX are you interested in working on it on your fork or would you rather I fork it?
 
Does the logging class log to the console?
And how do I use it? XD
 
@ArtOfCode wait, what? Is event None? That shouldn't happen.
@overactor I'll work on it, but every help is welcome :)
 
According to that error it is
I've set the command up in the same way you've got yours
    def command_points(args, msg, event):
	    return event.user.name
 
In which file?
 
@ProgramFOX Cool, I suppose I'll clone and see if I can get it running on my local machine
 
9:28 AM
Commands.py
 
@ArtOfCode Should work. Can you please fork my repo and push your changes there so I can take a look?
 
And added the command to the self.commands dictionary in Chatbot.py
yep, gimme a moment
 
ok, let me take a look
@ArtOfCode Unrelated, but you are mixing up tabs and spaces. Use 4 spaces for indentation, no tabs.
 
@ProgramFOX yeah my editor defaults to tabs and I forget to replace them. I've done it now
 
I don't see anything wrong... no idea why it gives that error.
 
9:40 AM
Bot started.
 
can you post a full stack trace?
 
Got it: line 201 in Chatbot.py: command_out = self.command(command_in, None, None)
 
Aha!
Clearly it gives that error because when you are running it from the console there is no chat message.
 
doh
 
run the command from chat and you'll be fine
 
9:43 AM
Bot started.
 
user153821
>>points
 
@KarmaBot KarmaBot
 
user153821
OK so that works now
 
Btw @ArtOfCode I'll clone your bot and remove everything (or at least as much as possible) stuff that's only Den-related because you won't need that anyway.
 
Ta, I'll give you access to the repo on my account so you can just push there
 
9:45 AM
argh I cannot fork a fork -_-
@ArtOfCode oh, thanks, that avoids that^ problem
 
Done
And going off again. I should probably not be doing this in school :)
 
Cya!
 
Why can't I seem to install cygwin?
oh, I'm on a 32 bit system
 
Okay @Art I removed everything that's specific to the Den.
That was a huge cleanup.
and there may be still some very minor traces left which could be easily removed
> 7 additions and 508 deletions
 
@ProgramFOX Wow, that nearly cut the codebase in half
 
9:57 AM
Yeah, indeed.
The original purpose of the bot was originally only that room, actually, but I added a thing so people where able to disable those features.
 
@ProgramFOX Makes sense that it was the biggest chunk then
do you have any thoughts on how to approach the refactoring?
 
The biggest part of the refactoring would be the room-specific code.
My approach would be to refactor piece by piece, so there are small refactorings everywhere which will clean up the code a lot after a while.
 
I'm an idiot
I'm installing cygwin on my windows machine so I can run setup.sh
Which of course doesn't work
because it's a setup for a linux machine
 
Read yesterday's conversation, you'll have to run the setup.py files for the dependencies.
17 hours ago, by ProgramFOX
@ArtOfCode Install https://pypi.python.org/pypi/setuptools first
and then the three dependencies listed here: chat.stackexchange.com/transcript/message/22450274#22450274
 
10:14 AM
I already had pip
I got the dependencies now
 
10:49 AM
@ProgramFOX I'm getting No module named bs4 on from bs4 import BeautifulSoup
But I have beautifulSoup installed
 
11:10 AM
@ArtOfCode when trying to run the bot did you ever get:
raise ValueError("invalid host: %r" % (host,))
Oh, I'm passed that now
Bot started.
>>xkcd 948
+command xkcd 948
whoops
Command not found.
Command not found.
@ProgramFOX It's not finding any commands it seems
Bot started.
 
11:30 AM
returns from lunch
 
I hope it was a nice lunch
 
@overactor Link to the dependency? You need to have Beautiful Soup 4 installed.
 
Bot started.
@ProgramFOX Yeah, I felt stupid after I figured that one out
 
@overactor What are you typing on the console?
 
The next problem was solved by updating requests
 
11:33 AM
ah
 
$-commands listcommands
or +
 
It's $-listcommands, not $-commands listcommands
 
whelp
I'll go and jump out of the window now
Commands: alive, help, listcommands, random, randomchoice, randomint, shuffle, translate, utc, xkcd, xkcdrandomnumber
 
>>listcommands
 
@ProgramFOX Commands: alive, help, listcommands, random, randomchoice, randomint, shuffle, translate, utc, xkcd, xkcdrandomnumber
at least I finally got it running now.
Wasn't so hard in the end, I'm just thick :)
 
11:36 AM
Running in on Windows isn't too easy. I still managed to build it on Windows somehow :P
 
 
1 hour later…
1:00 PM
@ProgramFOX :
import Settings


class MetaModule:
    def __init__(self, modules):
        self.modules = modules

    def command(self, name, args, msg, event):
        for module in self.modules:
            response = module.command(name, args, msg, event)
            if response:
               break
        return response

    def help(self, name):
        for module in self.modules:
            response = module.help(name)
            if response:
               break
        return response


class Module(MetaModule):
does that seem usable?
 
that looks good
 
Chatbot would then have a MetaModule object
which can contain modules and metamodules
What do you think is the best way to populate that object?
We could have a manifest sort of file (.py) with a dict of names and filenames
 
Yeah, a manifest file should work.
 
How exactly do the module files look then?
I'll try and write a simple one
 
How they look like... hmm...
 
1:07 PM
just a single MetaModule object?
 
That depends on how they exactly get populated, I'd say.
 
Does that work?
 
I believe that works.
 
wait, I think I've got an idea
The loading a module into a MetaModule logic needs to go into the MetaModule class
 
1:29 PM
@ProgramFOX, ok second go:
class MetaModule:
    def __init__(self, modules):
        self.modules = []
        for module in modules:
            self.modules.append(load_module(module))

    ...

    def load_module(self, file):
        module_file = __import__(file)
        module_file.run()
        return module_file.module
 
looks good
 
SimpleModule.py:
from Module import Module, Command

module = Module( [
    Command('test1', exec_test1, 'this is test1', false),
    Command('test2', exec_test2, 'this is test2', false),
] )

def exec_test1(args, msg, event):
    return "I'm in test1"

def exec_test2(args, msg, event):
    return "I'm in test2"
SimpleMetaModule.py:
from Module import MetaModule

module = MetaModule( [
    'SimpleModule.py'
] )
 
nice!
 
That makes the manifest file a MetaModule file
Haven't tested It yet though
 
1:44 PM
It needed some changes, but it's working
I'me going crazy having to write 'self' constantly in python
 
2:24 PM
@ProgramFOX Okay, I'm ready to commit what I have so far
Should I fork and send a pull request or can i get push rights?
 
Great!
@overactor I can give push rights. GitHub username?
 
same as here
 
Okay, you should have push rights now.
 
There we go
 
Awesome! Thanks.
 
2:33 PM
I haven't integrated it into the rest of the codebase at all yet.
 
GitHub says you have to check your commit email @overactor
 
When you have time, you can try it out on the console a bit and ask me if there are any problems
 
@overactor help appears to be a built-in command, I believe it's better if we don't override it.
 
@ProgramFOX Hmm
Could we not hijack it and send it to the parent if we don't find anything?
 
Same for list, which is used as a variable name somewhere.
 
2:37 PM
ah
as a python function you mean?
 
yeah
 
yeah sure, we can change those names
Any ideas for names?
 
I just pushed a new commit with the function renamed to get_help and the variable to cmd_list.
 
@ProgramFOX that should do it
Do you have a clear picture in your mind as to how to integrate this into the rest of the program?
I have a vague idea, but I can't properly express it at the moment and am not sure if it's correct
It's definitely not complete
 
I believe we can load the modules and add their commands to the command dictionary.
 
2:47 PM
The way I saw it is ChatBot having one module object
(metamodule)
 
Yeah, I meant we can load the modules from the metamodule object, because that's where they are stored.
 
Then we don't need a command dictionary anymore though
 
That's true.
 
we can just call modules.execute(name, args, msg, event)
after parsing the message
return modules.execute(name, args, msg, event) or "Command: '" + name + "' does not exist."
 
Then we will loop through them all and check if the command exists for any of them.
 
2:52 PM
@ProgramFOX Not necessary, the MetaModule does it automatically
 
Ah, right
 
maybe instead of relying on the Settings file, we could just send a boolean argument is_privileged_user?
Or are there more things you'll need data that is now in ChatBot.py for?
 
I pushed a commit that makes MetaModule return "Command not found." or "Help not found." when appropriate.
@overactor Everything is in Chatbot.py to avoid having static/shared/global variables.
 
@ProgramFOX Then you can't have multiple metamodules anymore though
 
Wait, do we have multiple MetaModules too?
 
2:58 PM
@ProgramFOX It's an option
encapsulation and all that
A user can make a metamodule if they want to
 
Fix pushed.
 
And add it to the 'Master MetaModule' just like a normal Module
 
MetaMetaModule
 
@ProgramFOX We can go deeper
I expect we won't have many MetaMetaModules though.
 
I'm only wondering how we are going to handle modules which require changes to the bot's core (extra if statements and such, like the code for that one room).
 
3:02 PM
@ProgramFOX Well, the logic for each module has to be encapsulated
 
But that could mean there is duplicated logic.
 
@ProgramFOX Can you give a possible example?
 
That's 3 extra lines for a specific room.
If it would be in a module, they couldn't simply be injected there.
 
@ProgramFOX Why do they need to be in the ChatBot class though?
This logic is irrelevant to everything but that one module
 
Hm, that's true.
 
3:08 PM
Wait, what exactly do those lines do?
 
it's a thing for this room, the bot is also a "word association game bot", those lines are for that purpose
 
@ProgramFOX So this doesn't change how the bot processes input right?
Or what it will reply to
 
Then we can encapsulate it
I gotta go
See you later, I'll be back on in a few hours
 
cya
 

« first day    last day (483 days later) »