Compare commits

..

1 Commits

Author SHA1 Message Date
Art Yerkes
3a3d839af3 Simple jmpbuf for powerpc.
svn path=/branches/powerpc/; revision=14757
2005-04-23 04:31:11 +00:00
25359 changed files with 2243649 additions and 6733724 deletions

View File

@@ -12,11 +12,18 @@
#include "trim.h"
#include "IRCClient.h"
#include "config.h"
using std::string;
using std::vector;
#if defined(_DEBUG) && 0
const char* BOTNAME = "RoyBot";
const char* CHANNEL = "#RoyBotTest";
#else
const char* BOTNAME = "ArchBlackmann";
const char* CHANNEL = "#ReactOS";
#endif
//vector<string> tech, module, dev, stru, period, status, type, func, irql, curse, cursecop;
class List
@@ -150,46 +157,14 @@ bool isop ( const string& who )
return false;
}
// do custom stuff with the IRCClient from your subclass via the provided callbacks...
class MyIRCClient : public IRCClient
{
File flog;
clock_t brake_silence;
// wait another 30 mins to brake the silence
#define NOIDLE brake_silence = clock () + 30 * CLK_TCK * 60
void CheckIdle ( void )
{
while (true) // _inRun
{
while (clock() < brake_silence)
Sleep(10000);
string out = TaggedReply("idle");
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
Action ( CHANNEL, &out[4] );
else
PrivMsg ( CHANNEL, out );
NOIDLE;
}
}
static void THREADAPI CallMe ( MyIRCClient* irc )
{
irc->CheckIdle();
}
public:
MyIRCClient()
{
NOIDLE;
ThreadPool::Instance().Launch ( (ThreadPoolFunc*)MyIRCClient::CallMe, this );
flog.open ( "arch.log", "r+" );
flog.open ( "arch.log", "w+" );
}
// see IRCClient.h for documentation on these callbacks...
bool OnConnected()
@@ -198,18 +173,17 @@ public:
}
bool OnJoin ( const string& user, const string& channel )
{
//printf ( "user '%s' joined channel '%s'\n", user.c_str(), channel.c_str() );
printf ( "user '%s' joined channel '%s'\n", user.c_str(), channel.c_str() );
return true;
}
bool OnPart ( const std::string& user, const std::string& channel )
{
std::vector<std::string>::iterator it = ops.begin();
for ( ; it != ops.end(); it++ )
for ( int i = 0; i < ops.size(); i++ )
{
if ( *it == user )
if ( ops[i] == user )
{
printf ( "remove '%s' to ops list\n", user.c_str() );
ops.erase ( it );
ops.erase ( &ops[i] );
}
}
return true;
@@ -233,18 +207,11 @@ public:
}
bool OnPrivMsg ( const string& from, const string& text )
{
//flog.flush();
printf ( "<%s> %s\n", from.c_str(), text.c_str() );
flog.printf ( "<%s> %s\n", from.c_str(), text.c_str() );
if ( !isop(from) )
if ( strnicmp ( text.c_str(), "!say ", 5 ) || !isop(from) )
return PrivMsg ( from, "hey, your tongue doesn't belong there!" );
else if ( strnicmp ( text.c_str(), "!say ", 5 ) )
return PrivMsg ( from, "Talk to me on normal Chanel" );
string say = trim(&text[5]);
if ( !strnicmp ( say.c_str(), "/me ", 4 ) )
return Action ( CHANNEL, trim(&say[4]) );
else
@@ -252,178 +219,140 @@ public:
}
bool OnChannelMsg ( const string& channel, const string& from, const string& text )
{
fflush ( flog );
printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() );
flog.printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() );
NOIDLE; // add 30 mins till idle
bool found_name = false;
string text2 ( text );
strlwr ( &text2[0] );
if ( !strnicmp ( text.c_str(), BOTNAME, strlen(BOTNAME) ) )
found_name = true;
string s ( text );
else if ( !strnicmp ( text.c_str(), "arch ", 5 ) )
found_name = true;
if ( found_name )
gobble ( s, " \t" ); // remove bot name
// command
if ( s[0] == '!' )
{
bool from_op = isop(from);
string cmd = gobble ( s, " \t" );
// from all
if ( false && cmd == "!svn" && from == "TechBot" ) // || cmd == "!help" && !TechBotOnline
string s ( text );
gobble ( s, " \t" ); // remove bot name
found_name = true;
if ( s[0] == '!' )
{
PrivMsg ( channel, "For my help try !what." );
}
// from normel user
else if ( !from_op )
{
if ( cmd == "!grovel" )
bool from_op = isop(from);
string cmd = gobble ( s, " \t" );
if ( !from_op )
{
string out = ssprintf(TaggedReply("nogrovel").c_str(),from.c_str());
if ( cmd == "!grovel" )
{
string out = ssprintf(TaggedReply("nogrovel").c_str(),from.c_str());
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
return Action ( channel, &out[4] );
else
return PrivMsg ( channel, out );
}
return PrivMsg ( channel, ssprintf("%s: I don't take commands from non-ops",from.c_str()) );
}
if ( cmd == "!add" )
{
string listname = gobble ( s, " \t" );
int i = GetListIndex ( listname.c_str() );
if ( i == -1 )
return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) );
List& list = lists[i];
if ( s[0] == '\"' || s[0] == '\'' )
{
char delim = s[0];
const char* p = &s[1];
const char* p2 = strchr ( p, delim );
if ( !p2 )
return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) );
s = string ( p, p2-p );
}
for ( i = 0; i < list.list.size(); i++ )
{
if ( list.list[i] == s )
return PrivMsg ( channel, ssprintf("%s: entry already exists in list '%s'",from.c_str(),listname.c_str()) );
}
if ( !stricmp ( listname.c_str(), "curse" ) )
strlwr ( &s[0] );
list.list.push_back ( s );
{
File f ( ssprintf("%s.txt",list.name.c_str()), "w" );
for ( i = 0; i < list.list.size(); i++ )
f.printf ( "%s\n", list.list[i].c_str() );
}
return PrivMsg ( channel, ssprintf("%s: entry added to list '%s'",from.c_str(),listname.c_str()) );
}
else if ( cmd == "!remove" )
{
string listname = gobble ( s, " \t" );
int i = GetListIndex ( listname.c_str() );
if ( i == -1 )
return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) );
List& list = lists[i];
if ( s[0] == '\"' || s[0] == '\'' )
{
char delim = s[0];
const char* p = &s[1];
const char* p2 = strchr ( p, delim );
if ( !p2 )
return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) );
s = string ( p, p2-p );
}
for ( i = 0; i < list.list.size(); i++ )
{
if ( list.list[i] == s )
{
list.list.erase ( &list.list[i] );
{
File f ( ssprintf("%s.txt",list.name.c_str()), "w" );
for ( i = 0; i < list.list.size(); i++ )
f.printf ( "%s\n", list.list[i].c_str() );
}
return PrivMsg ( channel, ssprintf("%s: entry removed from list '%s'",from.c_str(),listname.c_str()) );
}
}
return PrivMsg ( channel, ssprintf("%s: entry doesn't exist in list '%s'",from.c_str(),listname.c_str()) );
}
else if ( cmd == "!grovel" )
{
string out = ssprintf(TaggedReply("grovel").c_str(),from.c_str());
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
return Action ( channel, &out[4] );
else
return PrivMsg ( channel, out );
}
else if ( cmd == "!what" )
else if ( cmd == "!kiss" )
{
return PrivMsg ( channel, ssprintf("For you, %s, I only support the \"!grovel\" command.", from.c_str()).c_str() );
if ( s.size() )
return Action ( channel, ssprintf("kisses %s",s.c_str()) );
else
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
}
else if ( cmd == "!grovel" || cmd == "!kiss" || cmd == "!hug"
|| cmd == "!give" || cmd == "!what" || cmd == "!add" || cmd == "!remove" )
else if ( cmd == "!hug" )
{
PrivMsg ( channel, ssprintf("%s: I only take commands from ops",from.c_str()) );
if ( s.size() )
return Action ( channel, ssprintf("hugs %s",s.c_str()) );
else
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
}
else if ( cmd == "!give" )
{
string who = gobble(s," \t");
if ( who.size() && s.size() )
return Action ( channel, ssprintf("gives %s a %s",who.c_str(),s.c_str()) );
else
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
}
}
// from op
else if ( cmd == "!grovel" )
{
string out = ssprintf(TaggedReply("grovel").c_str(),from.c_str());
if ( !strnicmp ( out.c_str(), "/me ", 4 ) )
return Action ( channel, &out[4] );
else
return PrivMsg ( channel, out );
}
else if ( cmd == "!kiss" )
{
if ( s.size() )
return Action ( channel, ssprintf("kisses %s",s.c_str()) );
else
{
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
}
else if ( cmd == "!hug" )
{
if ( s.size() )
return Action ( channel, ssprintf("hugs %s",s.c_str()) );
else
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
}
else if ( cmd == "!give" )
{
string who = gobble(s," \t");
if ( who.size() && s.size() )
return Action ( channel, ssprintf("gives %s a %s",who.c_str(),s.c_str()) );
else
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
}
else if ( cmd == "!what" )
{
PrivMsg ( channel, "For ops I support the following commands:" );
PrivMsg ( channel, "!grovel" );
PrivMsg ( channel, "!kiss" );
PrivMsg ( channel, "!hug" );
PrivMsg ( channel, "!give" );
PrivMsg ( channel, "!say (the input is a private message)" );
PrivMsg ( channel, "!add" );
PrivMsg ( channel, "!remove" );
PrivMsg ( channel, " - for more info see wiki" );
}
else if ( cmd == "!add" )
{
string listname = gobble ( s, " \t" );
int i = GetListIndex ( listname.c_str() );
if ( i == -1 )
return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) );
List& list = lists[i];
if ( s[0] == '\"' || s[0] == '\'' )
{
char delim = s[0];
const char* p = &s[1];
const char* p2 = strchr ( p, delim );
if ( !p2 )
return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) );
s = string ( p, p2-p );
}
for ( i = 0; i < list.list.size(); i++ )
{
if ( list.list[i] == s )
return PrivMsg ( channel, ssprintf("%s: entry already exists in list '%s'",from.c_str(),listname.c_str()) );
}
if ( !stricmp ( listname.c_str(), "curse" ) )
strlwr ( &s[0] );
list.list.push_back ( s );
{
File f ( ssprintf("%s.txt",list.name.c_str()), "w" );
for ( i = 0; i < list.list.size(); i++ )
f.printf ( "%s\n", list.list[i].c_str() );
}
return PrivMsg ( channel, ssprintf("%s: entry added to list '%s'",from.c_str(),listname.c_str()) );
}
else if ( cmd == "!remove" )
{
string listname = gobble ( s, " \t" );
int i = GetListIndex ( listname.c_str() );
if ( i == -1 )
return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) );
List& list = lists[i];
if ( s[0] == '\"' || s[0] == '\'' )
{
char delim = s[0];
const char* p = &s[1];
const char* p2 = strchr ( p, delim );
if ( !p2 )
return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) );
s = string ( p, p2-p );
}
std::vector<std::string>::iterator it = list.list.begin();
for ( ; it != list.list.end(); it++ )
{
if ( *it == s )
{
list.list.erase ( it );
{
File f ( ssprintf("%s.txt",list.name.c_str()), "w" );
it = list.list.begin();
for ( ; it < list.list.end(); it++ )
f.printf ( "%s\n", it->c_str() );
}
return PrivMsg ( channel, ssprintf("%s: entry removed from list '%s'",from.c_str(),listname.c_str()) );
}
}
return PrivMsg ( channel, ssprintf("%s: entry doesn't exist in list '%s'",from.c_str(),listname.c_str()) );
}
else
{
if (found_name)
return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) );
}
} // if (command)
}
bool found_curse = false;
static vector<string>& curse = GetList("curse").list;
text2 = " " + text2 + " ";
text2 = ssprintf(" %s ",text2.c_str());
for ( int i = 0; i < curse.size() && !found_curse; i++ )
{
if ( strstr ( text2.c_str(), curse[i].c_str() ) )
@@ -434,12 +363,7 @@ public:
static List& cursecop = GetList("cursecop");
return PrivMsg ( channel, ssprintf("%s: %s", from.c_str(), ListRand(cursecop)) );
}
string botname (BOTNAME);
strlwr ( &botname[0] );
//botname = " " + botname + " ";
if ( strstr(text2.c_str(), botname.c_str()) || strstr(text2.c_str(), " arch ") || found_name )
else if ( found_name )
{
string out = ssprintf("%s: %s", from.c_str(), TaggedReply("tech").c_str());
flog.printf ( "TECH-REPLY: %s\n", out.c_str() );
@@ -449,9 +373,7 @@ public:
return PrivMsg ( channel, out );
}
return true;
} // On Chanel Message
}
bool OnChannelMode ( const string& channel, const string& mode )
{
//printf ( "OnChannelMode(%s,%s)\n", channel.c_str(), mode.c_str() );
@@ -483,13 +405,12 @@ public:
{
if ( *p == 'o' )
{
std::vector<std::string>::iterator it = ops.begin();
for ( ; it != ops.end(); it++ )
for ( int i = 0; i < ops.size(); i++ )
{
if ( *it == target )
if ( ops[i] == target )
{
printf ( "remove '%s' to ops list\n", target.c_str() );
ops.erase ( it );
ops.erase ( &ops[i] );
}
}
break;
@@ -518,16 +439,6 @@ public:
//printf ( "\n" );
return true;
}
bool OnKick ( void )
{
Join(CHANNEL);
return true;
}
bool OnBanned ( const std::string& channel )
{
Sleep(10000);
return Join(CHANNEL);
}
};
int main ( int argc, char** argv )
@@ -550,59 +461,50 @@ int main ( int argc, char** argv )
ImportList ( "cursecop", false );
ImportList ( "grovel", false );
ImportList ( "nogrovel", false );
ImportList ( "idle", false );
#ifdef _DEBUG
printf ( "initializing IRCClient debugging\n" );
IRCClient::SetDebug ( true );
#endif//_DEBUG
printf ( "calling suStartup()\n" );
suStartup();
printf ( "creating IRCClient object\n" );
MyIRCClient irc;
printf ( "connecting to freenode\n" );
while (true)
//const char* server = "212.204.214.114";
const char* server = "irc.freenode.net";
if ( !irc.Connect ( server ) ) // irc.freenode.net
{
printf ( "calling suStartup()\n" );
suStartup();
printf ( "creating IRCClient object\n" );
MyIRCClient irc;
printf ( "connecting to freenode\n" );
if ( !irc.Connect ( SERVER ) ) // irc.freenode.net
{
printf ( "couldn't connect to server\n" );
Sleep(10000);
continue;
}
printf ( "sending user command\n" );
if ( !irc.User ( BOTNAME, "reactos.com", SERVER, "ArchBlackmann" ) )
{
printf ( "USER command failed, retying ...\n" );
Sleep(10000);
continue;
}
printf ( "sending nick\n" );
if ( !irc.Nick ( BOTNAME ) )
{
printf ( "NICK command failed, retying ...\n" );
Sleep(10000);
continue;
}
printf ( "setting mode\n" );
if ( !irc.Mode ( MODE ) )
{
printf ( "MODE command failed, retying ...\n" );
Sleep(10000);
continue;
}
printf ( "joining channel\n" );
if ( !irc.Join ( CHANNEL ) )
{
printf ( "JOIN command failed, retying ...\n" );
Sleep(10000);
continue;
}
printf ( "entering irc client processor\n" );
irc.Run ( false ); // do the processing in this thread...
printf ( "couldn't connect to server\n" );
return -1;
}
printf ( "sending user command\n" );
if ( !irc.User ( BOTNAME, "", "irc.freenode.net", BOTNAME ) )
{
printf ( "USER command failed\n" );
return -1;
}
printf ( "sending nick\n" );
if ( !irc.Nick ( BOTNAME ) )
{
printf ( "NICK command failed\n" );
return -1;
}
printf ( "setting mode\n" );
if ( !irc.Mode ( "+i" ) )
{
printf ( "MODE command failed\n" );
return -1;
}
printf ( "joining channel\n" );
if ( !irc.Join ( CHANNEL ) )
{
printf ( "JOIN command failed\n" );
return -1;
}
printf ( "entering irc client processor\n" );
irc.Run ( false ); // do the processing in this thread...
return 0;
}

View File

@@ -110,10 +110,6 @@ SOURCE=.\chomp.h
# End Source File
# Begin Source File
SOURCE=.\config.h
# End Source File
# Begin Source File
SOURCE=.\cram_md5.cpp
# End Source File
# Begin Source File

View File

@@ -14,8 +14,8 @@
#define nelem(x) ( sizeof(x) / sizeof(x[0]) )
#endif//nelem
typedef File::filesize_t filesize_t;
typedef File::fileoff_t fileoff_t;
using File::filesize_t;
using File::fileoff_t;
fileoff_t File::seek ( fileoff_t offset )

View File

@@ -18,7 +18,7 @@
class File
{
public:
#ifdef WIN32
#ifdef _MSC_VER
typedef __int64 fileoff_t;
typedef unsigned __int64 filesize_t;
#else//_MSC_VER

View File

@@ -10,13 +10,12 @@
#include <sstream>
#include "IRCClient.h"
#include "MD5.h"
#include "md5.h"
#include "cram_md5.h"
#include "trim.h"
#include "chomp.h"
#include "SplitJoin.h"
#include "base64.h"
#include "config.h"
using std::string;
using std::stringstream;
@@ -24,8 +23,6 @@ using std::vector;
bool IRCClient::_debug = true;
// see rfc1459 for IRC-Protocoll Reference
IRCClient::IRCClient()
: _timeout(10*60*1000), _inRun(false)
{
@@ -54,9 +51,7 @@ bool
IRCClient::Nick ( const string& nick )
{
_nick = nick;
Send ( "NICK " + _nick + "\n" );
PrivMsg ("NickServ", "IDENTIFY " + (string)PASS);
return true;
return Send ( "NICK " + _nick + "\n" );
}
bool
@@ -80,7 +75,7 @@ IRCClient::Mode ( const string& channel, const string& mode, const string& targe
bool
IRCClient::Join ( const string& channel )
{
return Send("JOIN " + channel + "\n");
return Send ( "JOIN " + channel + "\n" );
}
bool
@@ -150,7 +145,7 @@ int IRCClient::Run ( bool launch_thread )
{
ThreadPool::Instance().Launch ( (ThreadPoolFunc*)IRCClient::Callback, this );
return 1;
}
}
_inRun = true;
if ( _debug ) printf ( "IRCClient::Run() - waiting for responses\n" );
string buf;
@@ -301,7 +296,6 @@ int IRCClient::Run ( bool launch_thread )
}
else if ( cmd == "join" )
{
mychannel = text;
OnJoin ( src, text );
}
else if ( cmd == "part" )
@@ -312,20 +306,14 @@ int IRCClient::Run ( bool launch_thread )
{
OnNick ( src, text );
}
else if ( cmd == "kick" )
{
OnKick ();
}
else if ( isdigit(cmd[0]) )
{
int i = atoi(cmd.c_str());
switch ( i )
{
case 1: // "Welcome!" - i.e. it's okay to issue commands now...
OnConnected();
break;
case 353: // user list for channel....
{
p = text.c_str();
@@ -348,7 +336,6 @@ int IRCClient::Run ( bool launch_thread )
OnChannelUsers ( channel, users );
}
break;
case 366: // END of user list for channel
{
p = text.c_str();
@@ -358,38 +345,6 @@ int IRCClient::Run ( bool launch_thread )
OnEndChannelUsers ( channel );
}
break;
case 474: // You are banned
{
p = text.c_str();
p2 = strpbrk ( p, " :" );
if ( !p2 ) continue;
string channel ( p, p2-p );
OnBanned ( channel );
}
break;
case 433: // Nick in Use
{
string nick = _nick;
Nick (nick + "_");
PrivMsg ("NickServ", "GHOST " + nick + " " + PASS);
// HACK HACK HACK
Mode ( "+i" );
Join ( CHANNEL ); // this is because IRC client does not review if his commands were sucessfull
Sleep ( 1000 );
Nick ( nick );
}
break;
case 2: //MOTD
case 376: //MOTD
case 372:
break;
default:
if ( _debug ) printf ( "unknown command %i: %s", i, buf.c_str() );
break;

View File

@@ -12,11 +12,9 @@
class IRCClient : public suBufferedRecvSocket
{
public:
IRCClient();
std::string mychannel;
static bool GetDebug() { return _debug; }
static bool SetDebug ( bool debug ) { bool old = _debug; _debug = debug; return old; }
@@ -101,12 +99,6 @@ public:
virtual bool OnChannelUsers ( const std::string& channel, const std::vector<std::string>& users )
{ return true; }
// OnKick: if the client has been kicked
virtual bool OnKick ( void ) { return true; }
// OnKick: if the client has been kicked
virtual bool OnBanned ( const std::string& channel ) { return true; }
// notification that you have received the entire list of users for a channel
virtual bool OnEndChannelUsers ( const std::string& channel ) { return true; }

View File

@@ -53,7 +53,7 @@ public:
{
ASSERT ( i < _end );
reserve ( i + 1 );
_arr[i].reset ( p );
_arr[i].reset ( ptr );
}
void push_back ( auto_ptr<T>& p )

View File

@@ -1,7 +0,0 @@
#define SERVER "irc.freenode.net"
#define BOTNAME "ArchBlackmann"
#define CHANNEL "#ReactOS"
#define MODE "+i"
#define PASS "ilovebunnies"

View File

@@ -2,7 +2,7 @@
// This file is (C) 2004 Royce Mitchell III
// and released under the BSD & LGPL licenses
#include "MD5.h"
#include "md5.h"
#include "cram_md5.h"
#include "base64.h"

View File

@@ -1 +1,26 @@
semprini
shit
fuck
pussy
ass
ass-
-ass
dumbass
jackass
fatass
asshole
smartass
cunt
fucker
bitch
dick
penile
stfu
omfg
lmao
ass.
-ass.
semprini
goat.cx
ekush
akshor
poop

View File

@@ -1,3 +1,4 @@
BOOLEAN
CcCanIWrite
CcCopyRead
CcCopyWrite

View File

@@ -1 +0,0 @@
/me is bored

View File

@@ -1,38 +0,0 @@
TARGET := ArchBlackmann.exe
.PHONY: all
all: $(TARGET)
CPP=mingw32-g++
CFLAGS := -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS
LFLAGS :=
LIBS := -lstdc++ -lws2_32
SRCS := ArchBlackmann.cpp \
base64.cpp \
chomp.cpp \
cram_md5.cpp \
File.cpp \
IRCClient.cpp \
MD5.cpp \
panic.cpp \
ReliMT.cpp \
SockUtils.cpp \
SplitJoin.cpp \
ssprintf.cpp \
ThreadPool.cpp \
trim.cpp
OBJS := $(SRCS:.cpp=.o)
$(TARGET): $(OBJS)
$(CPP) $(LFLAGS) -o $@ $(OBJS) $(LIBS)
.cpp.o: $<
$(CPP) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
-@del $(TARGET)
-@del $(OBJS)

View File

@@ -1,44 +0,0 @@
This doc can be also found on the wiki.
ArchBlackman is a IRC-Chat bot of the #reactos irc channel. He has been coded by Royce3 and DrFred (mbosma) currently runs him.
If some one use a swear word he'll tell him not to do so and you can also ask him something technical about reactos. :)
Besides this he also knows some commands. The systax for giving him commands "ArchBlackmann: !grovel". (don't forget to address him)
- !grovel - This is the only command that non ops can do (No Parameter)
- !kiss <person>
- !hug <person>
- !give <someone> <something>
- !say <something> - You can tell him to say something on the channel via PrivateMessage
ArchBlackmann know what he should say from some text files. They can be found on the svn-dir. But can also edit them online if you are op using:
- !add <list> <item>
- !remove <list> <item>
List that are used directly to create responses are:
- tech - here are the sentences ArchBlackmann says when he finds his name
- curse - this are the curses he looks for
- cursecop - this the responces to them
- grovel - this is said when an op does the grovel command
- nogrovel - this when someone else does it
The remaining lists are not used directly, but by the other lists.
They are:
- dev
- func
- irql
- module
- period
- status
- stru
- type
And they are used like this:
/me thinks %s is smarter than %dev%

View File

@@ -551,7 +551,7 @@ static bool numberfl(std::string& f, long double __n, char exp_sign, int size,
return true;
}
static int stringa(std::string& f, const char* s, int len, int field_width, int precision, int flags)
static int string(std::string& f, const char* s, int len, int field_width, int precision, int flags)
{
int i, done = 0;
if (s == NULL)
@@ -654,7 +654,7 @@ std::string ssvprintf ( const char *fmt, va_list args )
long double _ldouble;
double _double;
const char *s;
const wchar_t* sw;
const unsigned short* sw;
int result;
std::string f;
@@ -793,12 +793,12 @@ std::string ssvprintf ( const char *fmt, va_list args )
case 's':
if (qualifier == 'l' || qualifier == 'w') {
/* print unicode string */
sw = (const wchar_t*)va_arg(args, wchar_t *);
sw = va_arg(args, wchar_t *);
result = stringw(f, sw, -1, field_width, precision, flags);
} else {
/* print ascii string */
s = va_arg(args, char *);
result = stringa(f, s, -1, field_width, precision, flags);
result = string(f, s, -1, field_width, precision, flags);
}
if (result < 0)
{
@@ -811,10 +811,10 @@ std::string ssvprintf ( const char *fmt, va_list args )
if (qualifier == 'h') {
/* print ascii string */
s = va_arg(args, char *);
result = stringa(f, s, -1, field_width, precision, flags);
result = string(f, s, -1, field_width, precision, flags);
} else {
/* print unicode string */
sw = (const wchar_t*)va_arg(args, wchar_t *);
sw = va_arg(args, wchar_t *);
result = stringw(f, sw, -1, field_width, precision, flags);
}
if (result < 0)
@@ -846,7 +846,7 @@ std::string ssvprintf ( const char *fmt, va_list args )
s = pas->Buffer;
len = pas->Length;
}
result = stringa(f, s, -1, field_width, precision, flags);
result = string(f, s, -1, field_width, precision, flags);
}
if (result < 0)
return -1;

View File

@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{72E5CCA1-6318-4D62-964D-CB23A5C743B5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CHMLibrary</RootNamespace>
<AssemblyName>CHMLibrary</AssemblyName>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Category.cs" />
<Compile Include="CHMDecoding\BinaryReaderHelp.cs" />
<Compile Include="CHMDecoding\CHMBtree.cs" />
<Compile Include="CHMDecoding\CHMFile.cs" />
<Compile Include="CHMDecoding\CHMIdxhdr.cs" />
<Compile Include="CHMDecoding\CHMStrings.cs" />
<Compile Include="CHMDecoding\CHMSystem.cs" />
<Compile Include="CHMDecoding\CHMTocidx.cs" />
<Compile Include="CHMDecoding\CHMTopics.cs" />
<Compile Include="CHMDecoding\CHMUrlstr.cs" />
<Compile Include="CHMDecoding\CHMUrltable.cs" />
<Compile Include="CHMDecoding\DumpingInfo.cs" />
<Compile Include="CHMDecoding\enumerations.cs" />
<Compile Include="CHMDecoding\FullTextEngine.cs" />
<Compile Include="CHMDecoding\HHCParser.cs" />
<Compile Include="CHMDecoding\HHCParser2.cs" />
<Compile Include="CHMDecoding\HHKParser.cs" />
<Compile Include="CHMDecoding\TopicEntry.cs" />
<Compile Include="CHMDecoding\UrlTableEntry.cs" />
<Compile Include="ChmFileInfo.cs" />
<Compile Include="HtmlHelpSystem.cs" />
<Compile Include="HttpUtility.cs" />
<Compile Include="Index.cs" />
<Compile Include="IndexItem.cs" />
<Compile Include="IndexTopic.cs" />
<Compile Include="InformationType.cs" />
<Compile Include="Storage\CHMStream.cs" />
<Compile Include="TableOfContents.cs" />
<Compile Include="TOCItem.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Compression\Compression.csproj">
<Project>{E32307F1-623A-4E62-826F-56CDD4B23A54}</Project>
<Name>Compression</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@@ -1,65 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E32307F1-623A-4E62-826F-56CDD4B23A54}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Compression</RootNamespace>
<AssemblyName>Compression</AssemblyName>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Checksums\Adler32.cs" />
<Compile Include="Checksums\CRC32.cs" />
<Compile Include="Checksums\IChecksum.cs" />
<Compile Include="Checksums\StrangeCRC.cs" />
<Compile Include="Deflater.cs" />
<Compile Include="DeflaterConstants.cs" />
<Compile Include="DeflaterEngine.cs" />
<Compile Include="DeflaterHuffman.cs" />
<Compile Include="DeflaterPending.cs" />
<Compile Include="Inflater.cs" />
<Compile Include="InflaterDynHeader.cs" />
<Compile Include="InflaterHuffmanTree.cs" />
<Compile Include="PendingBuffer.cs" />
<Compile Include="Streams\DeflaterOutputStream.cs" />
<Compile Include="Streams\InflaterInputStream.cs" />
<Compile Include="Streams\OutputWindow.cs" />
<Compile Include="Streams\StreamManipulator.cs" />
<Compile Include="ZipException.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
</Project>

14
irc/TechBot/Default.build Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<project name="TechBot" default="build">
<target name="build" description="Build components">
<delete dir="bin" failonerror="false" />
<nant buildfile="Compression/Default.build" />
<nant buildfile="CHMLibrary/Default.build" />
<nant buildfile="TechBot.IRCLibrary/Default.build" />
<nant buildfile="TechBot.Library/Default.build" />
<nant buildfile="TechBot.Console/Default.build" />
<nant buildfile="TechBot/Default.build" />
</target>
</project>

View File

@@ -1,7 +1,5 @@
<?xml version="1.0" ?>
<HresultList>
<Hresult text="S_OK" value="00000000" />
<Hresult text="S_FALSE" value="00000001" />
<Hresult text="STG_S_CONVERTED" value="00030200" />
<Hresult text="STG_S_BLOCK" value="00030201" />
<Hresult text="STG_S_RETRYNOW" value="00030202" />

View File

@@ -2,69 +2,8 @@
<NtstatusList>
<Ntstatus text="STATUS_SUCCESS" value="00000000"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0" value="00000000"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 1" value="00000001"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 2" value="00000002"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 3" value="00000003"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 4" value="00000004"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 5" value="00000005"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 6" value="00000006"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 7" value="00000007"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 8" value="00000008"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 9" value="00000009"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 10" value="0000000A"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 11" value="0000000B"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 12" value="0000000C"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 13" value="0000000D"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 14" value="0000000E"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 15" value="0000000F"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 16" value="00000010"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 17" value="00000011"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 18" value="00000012"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 19" value="00000013"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 20" value="00000014"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 21" value="00000015"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 22" value="00000016"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 23" value="00000017"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 24" value="00000018"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 25" value="00000019"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 26" value="0000001A"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 27" value="0000001B"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 28" value="0000001C"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 29" value="0000001D"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 30" value="0000001E"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 31" value="0000001F"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 32" value="00000020"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 33" value="00000021"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 34" value="00000022"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 35" value="00000023"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 36" value="00000024"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 37" value="00000025"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 38" value="00000026"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 39" value="00000027"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 40" value="00000028"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 41" value="00000029"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 42" value="0000002A"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 43" value="0000002B"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 44" value="0000002C"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 45" value="0000002D"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 46" value="0000002E"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 47" value="0000002F"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 48" value="00000030"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 49" value="00000031"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 50" value="00000032"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 51" value="00000033"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 52" value="00000034"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 53" value="00000035"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 54" value="00000036"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 55" value="00000037"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 56" value="00000038"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 57" value="00000039"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 58" value="0000003A"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 59" value="0000003B"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 60" value="0000003C"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 61" value="0000003D"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 62" value="0000003E"></Ntstatus>
<Ntstatus text="STATUS_WAIT_0 + 63" value="0000003F"></Ntstatus>
<Ntstatus text="STATUS_WAIT_1" value="00000001"></Ntstatus>
<Ntstatus text="STATUS_WAIT_63" value="0000003F"></Ntstatus>
<Ntstatus text="STATUS_ABANDONED" value="00000080"></Ntstatus>
<Ntstatus text="STATUS_ABANDONED_WAIT_0" value="00000080"></Ntstatus>
<Ntstatus text="STATUS_ABANDONED_WAIT_63" value="000000BF"></Ntstatus>

View File

@@ -1,321 +0,0 @@
<?xml version="1.0" ?>
<WindowMessageList>
<WindowMessage text="WM_APP" value="32768" />
<WindowMessage text="WM_ACTIVATE" value="6" />
<WindowMessage text="WM_ACTIVATEAPP" value="28" />
<WindowMessage text="WM_AFXFIRST" value="864" />
<WindowMessage text="WM_AFXLAST" value="895" />
<WindowMessage text="WM_ASKCBFORMATNAME" value="780" />
<WindowMessage text="WM_CANCELJOURNAL" value="75" />
<WindowMessage text="WM_CANCELMODE" value="31" />
<WindowMessage text="WM_CAPTURECHANGED" value="533" />
<WindowMessage text="WM_CHANGECBCHAIN" value="781" />
<WindowMessage text="WM_CHANGEUISTATE" value="295" />
<WindowMessage text="WM_UPDATEUISTATE" value="296" />
<WindowMessage text="WM_QUERYUISTATE" value="297" />
<WindowMessage text="WM_CHAR" value="258" />
<WindowMessage text="WM_CHARTOITEM" value="47" />
<WindowMessage text="WM_CHILDACTIVATE" value="34" />
<WindowMessage text="WM_CLEAR" value="771" />
<WindowMessage text="WM_CLOSE" value="16" />
<WindowMessage text="WM_COMMAND" value="273" />
<WindowMessage text="WM_COMMNOTIFY" value="68" />
<WindowMessage text="WM_COMPACTING" value="65" />
<WindowMessage text="WM_COMPAREITEM" value="57" />
<WindowMessage text="WM_CONTEXTMENU" value="123" />
<WindowMessage text="WM_COPY" value="769" />
<WindowMessage text="WM_COPYDATA" value="74" />
<WindowMessage text="WM_CREATE" value="1" />
<WindowMessage text="WM_CTLCOLORBTN" value="309" />
<WindowMessage text="WM_CTLCOLORDLG" value="310" />
<WindowMessage text="WM_CTLCOLOREDIT" value="307" />
<WindowMessage text="WM_CTLCOLORLISTBOX" value="308" />
<WindowMessage text="WM_CTLCOLORMSGBOX" value="306" />
<WindowMessage text="WM_CTLCOLORSCROLLBAR" value="311" />
<WindowMessage text="WM_CTLCOLORSTATIC" value="312" />
<WindowMessage text="WM_CUT" value="768" />
<WindowMessage text="WM_DEADCHAR" value="259" />
<WindowMessage text="WM_DELETEITEM" value="45" />
<WindowMessage text="WM_DESTROY" value="2" />
<WindowMessage text="WM_DESTROYCLIPBOARD" value="775" />
<WindowMessage text="WM_DEVICECHANGE" value="537" />
<WindowMessage text="WM_DEVMODECHANGE" value="27" />
<WindowMessage text="WM_DISPLAYCHANGE" value="126" />
<WindowMessage text="WM_DRAWCLIPBOARD" value="776" />
<WindowMessage text="WM_DRAWITEM" value="43" />
<WindowMessage text="WM_DROPFILES" value="563" />
<WindowMessage text="WM_ENABLE" value="10" />
<WindowMessage text="WM_ENDSESSION" value="22" />
<WindowMessage text="WM_ENTERIDLE" value="289" />
<WindowMessage text="WM_ENTERMENULOOP" value="529" />
<WindowMessage text="WM_ENTERSIZEMOVE" value="561" />
<WindowMessage text="WM_ERASEBKGND" value="20" />
<WindowMessage text="WM_EXITMENULOOP" value="530" />
<WindowMessage text="WM_EXITSIZEMOVE" value="562" />
<WindowMessage text="WM_FONTCHANGE" value="29" />
<WindowMessage text="WM_GETDLGCODE" value="135" />
<WindowMessage text="WM_GETFONT" value="49" />
<WindowMessage text="WM_GETHOTKEY" value="51" />
<WindowMessage text="WM_GETICON" value="127" />
<WindowMessage text="WM_GETMINMAXINFO" value="36" />
<WindowMessage text="WM_GETTEXT" value="13" />
<WindowMessage text="WM_GETTEXTLENGTH" value="14" />
<WindowMessage text="WM_HANDHELDFIRST" value="856" />
<WindowMessage text="WM_HANDHELDLAST" value="863" />
<WindowMessage text="WM_HELP" value="83" />
<WindowMessage text="WM_HOTKEY" value="786" />
<WindowMessage text="WM_HSCROLL" value="276" />
<WindowMessage text="WM_HSCROLLCLIPBOARD" value="782" />
<WindowMessage text="WM_ICONERASEBKGND" value="39" />
<WindowMessage text="WM_INITDIALOG" value="272" />
<WindowMessage text="WM_INITMENU" value="278" />
<WindowMessage text="WM_INITMENUPOPUP" value="279" />
<WindowMessage text="WM_INPUTLANGCHANGE" value="81" />
<WindowMessage text="WM_INPUTLANGCHANGEREQUEST" value="80" />
<WindowMessage text="WM_KEYDOWN" value="256" />
<WindowMessage text="WM_KEYUP" value="257" />
<WindowMessage text="WM_KILLFOCUS" value="8" />
<WindowMessage text="WM_MDIACTIVATE" value="546" />
<WindowMessage text="WM_MDICASCADE" value="551" />
<WindowMessage text="WM_MDICREATE" value="544" />
<WindowMessage text="WM_MDIDESTROY" value="545" />
<WindowMessage text="WM_MDIGETACTIVE" value="553" />
<WindowMessage text="WM_MDIICONARRANGE" value="552" />
<WindowMessage text="WM_MDIMAXIMIZE" value="549" />
<WindowMessage text="WM_MDINEXT" value="548" />
<WindowMessage text="WM_MDIREFRESHMENU" value="564" />
<WindowMessage text="WM_MDIRESTORE" value="547" />
<WindowMessage text="WM_MDISETMENU" value="560" />
<WindowMessage text="WM_MDITILE" value="550" />
<WindowMessage text="WM_MEASUREITEM" value="44" />
<WindowMessage text="WM_MENURBUTTONUP" value="290" />
<WindowMessage text="WM_MENUCHAR" value="288" />
<WindowMessage text="WM_MENUSELECT" value="287" />
<WindowMessage text="WM_NEXTMENU" value="531" />
<WindowMessage text="WM_MOVE" value="3" />
<WindowMessage text="WM_MOVING" value="534" />
<WindowMessage text="WM_NCACTIVATE" value="134" />
<WindowMessage text="WM_NCCALCSIZE" value="131" />
<WindowMessage text="WM_NCCREATE" value="129" />
<WindowMessage text="WM_NCDESTROY" value="130" />
<WindowMessage text="WM_NCHITTEST" value="132" />
<WindowMessage text="WM_NCLBUTTONDBLCLK" value="163" />
<WindowMessage text="WM_NCLBUTTONDOWN" value="161" />
<WindowMessage text="WM_NCLBUTTONUP" value="162" />
<WindowMessage text="WM_NCMBUTTONDBLCLK" value="169" />
<WindowMessage text="WM_NCMBUTTONDOWN" value="167" />
<WindowMessage text="WM_NCMBUTTONUP" value="168" />
<WindowMessage text="WM_NCXBUTTONDOWN" value="171" />
<WindowMessage text="WM_NCXBUTTONUP" value="172" />
<WindowMessage text="WM_NCXBUTTONDBLCLK" value="173" />
<WindowMessage text="WM_NCMOUSEMOVE" value="160" />
<WindowMessage text="WM_NCMOUSEHOVER" value="0x02A0" />
<WindowMessage text="WM_NCMOUSELEAVE" value="0x02A2" />
<WindowMessage text="WM_NCPAINT" value="133" />
<WindowMessage text="WM_NCRBUTTONDBLCLK" value="166" />
<WindowMessage text="WM_NCRBUTTONDOWN" value="164" />
<WindowMessage text="WM_NCRBUTTONUP" value="165" />
<WindowMessage text="WM_NEXTDLGCTL" value="40" />
<WindowMessage text="WM_NEXTMENU" value="531" />
<WindowMessage text="WM_NOTIFY" value="78" />
<WindowMessage text="WM_NOTIFYFORMAT" value="85" />
<WindowMessage text="WM_NULL" value="0" />
<WindowMessage text="WM_PAINT" value="15" />
<WindowMessage text="WM_PAINTCLIPBOARD" value="777" />
<WindowMessage text="WM_PAINTICON" value="38" />
<WindowMessage text="WM_PALETTECHANGED" value="785" />
<WindowMessage text="WM_PALETTEISCHANGING" value="784" />
<WindowMessage text="WM_PARENTNOTIFY" value="528" />
<WindowMessage text="WM_PASTE" value="770" />
<WindowMessage text="WM_PENWINFIRST" value="896" />
<WindowMessage text="WM_PENWINLAST" value="911" />
<WindowMessage text="WM_POWER" value="72" />
<WindowMessage text="WM_POWERBROADCAST" value="536" />
<WindowMessage text="WM_PRINT" value="791" />
<WindowMessage text="WM_PRINTCLIENT" value="792" />
<WindowMessage text="WM_QUERYDRAGICON" value="55" />
<WindowMessage text="WM_QUERYENDSESSION" value="17" />
<WindowMessage text="WM_QUERYNEWPALETTE" value="783" />
<WindowMessage text="WM_QUERYOPEN" value="19" />
<WindowMessage text="WM_QUEUESYNC" value="35" />
<WindowMessage text="WM_QUIT" value="18" />
<WindowMessage text="WM_RENDERALLFORMATS" value="774" />
<WindowMessage text="WM_RENDERFORMAT" value="773" />
<WindowMessage text="WM_SETCURSOR" value="32" />
<WindowMessage text="WM_SETFOCUS" value="7" />
<WindowMessage text="WM_SETFONT" value="48" />
<WindowMessage text="WM_SETHOTKEY" value="50" />
<WindowMessage text="WM_SETICON" value="128" />
<WindowMessage text="WM_SETREDRAW" value="11" />
<WindowMessage text="WM_SETTEXT" value="12" />
<WindowMessage text="WM_SETTINGCHANGE" value="26" />
<WindowMessage text="WM_SHOWWINDOW" value="24" />
<WindowMessage text="WM_SIZE" value="5" />
<WindowMessage text="WM_SIZECLIPBOARD" value="779" />
<WindowMessage text="WM_SIZING" value="532" />
<WindowMessage text="WM_SPOOLERSTATUS" value="42" />
<WindowMessage text="WM_STYLECHANGED" value="125" />
<WindowMessage text="WM_STYLECHANGING" value="124" />
<WindowMessage text="WM_SYSCHAR" value="262" />
<WindowMessage text="WM_SYSCOLORCHANGE" value="21" />
<WindowMessage text="WM_SYSCOMMAND" value="274" />
<WindowMessage text="WM_SYSDEADCHAR" value="263" />
<WindowMessage text="WM_SYSKEYDOWN" value="260" />
<WindowMessage text="WM_SYSKEYUP" value="261" />
<WindowMessage text="WM_TCARD" value="82" />
<WindowMessage text="WM_TIMECHANGE" value="30" />
<WindowMessage text="WM_TIMER" value="275" />
<WindowMessage text="WM_SYSTIMER" value="280" />
<WindowMessage text="WM_UNDO" value="772" />
<WindowMessage text="WM_USER" value="1024" />
<WindowMessage text="WM_USERCHANGED" value="84" />
<WindowMessage text="WM_VKEYTOITEM" value="46" />
<WindowMessage text="WM_VSCROLL" value="277" />
<WindowMessage text="WM_VSCROLLCLIPBOARD" value="778" />
<WindowMessage text="WM_WINDOWPOSCHANGED" value="71" />
<WindowMessage text="WM_WINDOWPOSCHANGING" value="70" />
<WindowMessage text="WM_WININICHANGE" value="26" />
<WindowMessage text="WM_KEYFIRST" value="256" />
<WindowMessage text="WM_KEYLAST" value="264" />
<WindowMessage text="WM_SYNCPAINT" value="136" />
<WindowMessage text="WM_MOUSEACTIVATE" value="33" />
<WindowMessage text="WM_MOUSEMOVE" value="512" />
<WindowMessage text="WM_LBUTTONDOWN" value="513" />
<WindowMessage text="WM_LBUTTONUP" value="514" />
<WindowMessage text="WM_LBUTTONDBLCLK" value="515" />
<WindowMessage text="WM_RBUTTONDOWN" value="516" />
<WindowMessage text="WM_RBUTTONUP" value="517" />
<WindowMessage text="WM_RBUTTONDBLCLK" value="518" />
<WindowMessage text="WM_MBUTTONDOWN" value="519" />
<WindowMessage text="WM_MBUTTONUP" value="520" />
<WindowMessage text="WM_MBUTTONDBLCLK" value="521" />
<WindowMessage text="WM_MOUSEWHEEL" value="522" />
<WindowMessage text="WM_MOUSEFIRST" value="512" />
<WindowMessage text="WM_XBUTTONDOWN" value="523" />
<WindowMessage text="WM_XBUTTONUP" value="524" />
<WindowMessage text="WM_XBUTTONDBLCLK" value="525" />
<WindowMessage text="WM_MOUSELAST" value="525" />
<WindowMessage text="WM_MOUSEHOVER" value="0x2A1" />
<WindowMessage text="WM_MOUSELEAVE" value="0x2A3" />
<WindowMessage text="WM_THEMECHANGED" value="794" />
<WindowMessage text="BM_CLICK" value="245" />
<WindowMessage text="BM_GETCHECK" value="240" />
<WindowMessage text="BM_GETIMAGE" value="246" />
<WindowMessage text="BM_GETSTATE" value="242" />
<WindowMessage text="BM_SETCHECK" value="241" />
<WindowMessage text="BM_SETIMAGE" value="247" />
<WindowMessage text="BM_SETSTATE" value="243" />
<WindowMessage text="BM_SETSTYLE" value="244" />
<WindowMessage text="CB_ADDSTRING" value="323" />
<WindowMessage text="CB_DELETESTRING" value="324" />
<WindowMessage text="CB_DIR" value="325" />
<WindowMessage text="CB_FINDSTRING" value="332" />
<WindowMessage text="CB_FINDSTRINGEXACT" value="344" />
<WindowMessage text="CB_GETCOMBOBOXINFO" value="356" />
<WindowMessage text="CB_GETCOUNT" value="326" />
<WindowMessage text="CB_GETCURSEL" value="327" />
<WindowMessage text="CB_GETDROPPEDCONTROLRECT" value="338" />
<WindowMessage text="CB_GETDROPPEDSTATE" value="343" />
<WindowMessage text="CB_GETDROPPEDWIDTH" value="351" />
<WindowMessage text="CB_GETEDITSEL" value="320" />
<WindowMessage text="CB_GETEXTENDEDUI" value="342" />
<WindowMessage text="CB_GETHORIZONTALEXTENT" value="349" />
<WindowMessage text="CB_GETITEMDATA" value="336" />
<WindowMessage text="CB_GETITEMHEIGHT" value="340" />
<WindowMessage text="CB_GETLBTEXT" value="328" />
<WindowMessage text="CB_GETLBTEXTLEN" value="329" />
<WindowMessage text="CB_GETLOCALE" value="346" />
<WindowMessage text="CB_GETTOPINDEX" value="347" />
<WindowMessage text="CB_INITSTORAGE" value="353" />
<WindowMessage text="CB_INSERTSTRING" value="330" />
<WindowMessage text="CB_LIMITTEXT" value="321" />
<WindowMessage text="CB_RESETCONTENT" value="331" />
<WindowMessage text="CB_SELECTSTRING" value="333" />
<WindowMessage text="CB_SETCURSEL" value="334" />
<WindowMessage text="CB_SETDROPPEDWIDTH" value="352" />
<WindowMessage text="CB_SETEDITSEL" value="322" />
<WindowMessage text="CB_SETEXTENDEDUI" value="341" />
<WindowMessage text="CB_SETHORIZONTALEXTENT" value="350" />
<WindowMessage text="CB_SETITEMDATA" value="337" />
<WindowMessage text="CB_SETITEMHEIGHT" value="339" />
<WindowMessage text="CB_SETLOCALE" value="345" />
<WindowMessage text="CB_SETTOPINDEX" value="348" />
<WindowMessage text="CB_SHOWDROPDOWN" value="335" />
<WindowMessage text="EM_CANUNDO" value="198" />
<WindowMessage text="EM_CHARFROMPOS" value="215" />
<WindowMessage text="EM_EMPTYUNDOBUFFER" value="205" />
<WindowMessage text="EM_FMTLINES" value="200" />
<WindowMessage text="EM_GETFIRSTVISIBLELINE" value="206" />
<WindowMessage text="EM_GETHANDLE" value="189" />
<WindowMessage text="EM_GETLIMITTEXT" value="213" />
<WindowMessage text="EM_GETLINE" value="196" />
<WindowMessage text="EM_GETLINECOUNT" value="186" />
<WindowMessage text="EM_GETMARGINS" value="212" />
<WindowMessage text="EM_GETMODIFY" value="184" />
<WindowMessage text="EM_GETPASSWORDCHAR" value="210" />
<WindowMessage text="EM_GETRECT" value="178" />
<WindowMessage text="EM_GETSEL" value="176" />
<WindowMessage text="EM_GETTHUMB" value="190" />
<WindowMessage text="EM_GETWORDBREAKPROC" value="209" />
<WindowMessage text="EM_LIMITTEXT" value="197" />
<WindowMessage text="EM_LINEFROMCHAR" value="201" />
<WindowMessage text="EM_LINEINDEX" value="187" />
<WindowMessage text="EM_LINELENGTH" value="193" />
<WindowMessage text="EM_LINESCROLL" value="182" />
<WindowMessage text="EM_POSFROMCHAR" value="214" />
<WindowMessage text="EM_REPLACESEL" value="194" />
<WindowMessage text="EM_SCROLL" value="181" />
<WindowMessage text="EM_SCROLLCARET" value="183" />
<WindowMessage text="EM_SETHANDLE" value="188" />
<WindowMessage text="EM_SETLIMITTEXT" value="197" />
<WindowMessage text="EM_SETMARGINS" value="211" />
<WindowMessage text="EM_SETMODIFY" value="185" />
<WindowMessage text="EM_SETPASSWORDCHAR" value="204" />
<WindowMessage text="EM_SETREADONLY" value="207" />
<WindowMessage text="EM_SETRECT" value="179" />
<WindowMessage text="EM_SETRECTNP" value="180" />
<WindowMessage text="EM_SETSEL" value="177" />
<WindowMessage text="EM_SETTABSTOPS" value="203" />
<WindowMessage text="EM_SETWORDBREAKPROC" value="208" />
<WindowMessage text="EM_UNDO" value="199" />
<WindowMessage text="LB_ADDFILE" value="406" />
<WindowMessage text="LB_ADDSTRING" value="384" />
<WindowMessage text="LB_DELETESTRING" value="386" />
<WindowMessage text="LB_DIR" value="397" />
<WindowMessage text="LB_FINDSTRING" value="399" />
<WindowMessage text="LB_FINDSTRINGEXACT" value="418" />
<WindowMessage text="LB_GETANCHORINDEX" value="413" />
<WindowMessage text="LB_GETCARETINDEX" value="415" />
<WindowMessage text="LB_GETCOUNT" value="395" />
<WindowMessage text="LB_GETCURSEL" value="392" />
<WindowMessage text="LB_GETHORIZONTALEXTENT" value="403" />
<WindowMessage text="LB_GETITEMDATA" value="409" />
<WindowMessage text="LB_GETITEMHEIGHT" value="417" />
<WindowMessage text="LB_GETITEMRECT" value="408" />
<WindowMessage text="LB_GETLOCALE" value="422" />
<WindowMessage text="LB_GETSEL" value="391" />
<WindowMessage text="LB_GETSELCOUNT" value="400" />
<WindowMessage text="LB_GETSELITEMS" value="401" />
<WindowMessage text="LB_GETTEXT" value="393" />
<WindowMessage text="LB_GETTEXTLEN" value="394" />
<WindowMessage text="LB_GETTOPINDEX" value="398" />
<WindowMessage text="LB_INITSTORAGE" value="424" />
<WindowMessage text="LB_INSERTSTRING" value="385" />
<WindowMessage text="LB_ITEMFROMPOINT" value="425" />
<WindowMessage text="LB_RESETCONTENT" value="388" />
<WindowMessage text="LB_SELECTSTRING" value="396" />
<WindowMessage text="LB_SELITEMRANGE" value="411" />
<WindowMessage text="LB_SELITEMRANGEEX" value="387" />
<WindowMessage text="LB_SETANCHORINDEX" value="412" />
<WindowMessage text="LB_SETCARETINDEX" value="414" />
<WindowMessage text="LB_SETCOLUMNWIDTH" value="405" />
<WindowMessage text="LB_SETCOUNT" value="423" />
<WindowMessage text="LB_SETCURSEL" value="390" />
<WindowMessage text="LB_SETHORIZONTALEXTENT" value="404" />
<WindowMessage text="LB_SETITEMDATA" value="410" />
<WindowMessage text="LB_SETITEMHEIGHT" value="416" />
<WindowMessage text="LB_SETLOCALE" value="421" />
<WindowMessage text="LB_SETSEL" value="389" />
<WindowMessage text="LB_SETTABSTOPS" value="402" />
<WindowMessage text="LB_SETTOPINDEX" value="407" />
</WindowMessageList>

View File

@@ -1,42 +0,0 @@
using System;
using TechBot.Library;
namespace TechBot.Commands.Common
{
public abstract class BugCommand : Command
{
// private string m_BugID = null;
public BugCommand()
{
}
public string BugID
{
get { return Parameters; }
set { Parameters = value; }
}
public override void ExecuteCommand()
{
if (string.IsNullOrEmpty(BugID))
{
Say("Please provide a valid bug number.");
}
else
{
try
{
Say(BugUrl, Int32.Parse(BugID));
}
catch (Exception)
{
Say("{0} is not a valid bug number.", BugID);
}
}
}
protected abstract string BugUrl { get; }
}
}

View File

@@ -1,180 +0,0 @@
using System;
using System.Xml;
using System.Collections;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("error", Help = "!error <value>")]
public class ErrorCommand : Command
{
private NtStatusCommand ntStatus;
private WinErrorCommand winerror;
private HResultCommand hresult;
public ErrorCommand()
{
this.ntStatus = new NtStatusCommand();
this.winerror = new WinErrorCommand();
this.hresult = new HResultCommand();
}
private static int GetSeverity(long error)
{
return (int)((error >> 30) & 0x3);
}
private static bool IsCustomer(long error)
{
return (error & 0x20000000) != 0;
}
private static bool IsReserved(long error)
{
return (error & 0x10000000) != 0;
}
private static int GetFacility(long error)
{
return (int)((error >> 16) & 0xFFF);
}
private static short GetCode(long error)
{
return (short)((error >> 0) & 0xFFFF);
}
private static string FormatSeverity(long error)
{
int severity = GetSeverity(error);
switch (severity)
{
case 0: return "SUCCESS";
case 1: return "INFORMATIONAL";
case 2: return "WARNING";
case 3: return "ERROR";
}
return null;
}
private static string FormatFacility(long error)
{
int facility = GetFacility(error);
return facility.ToString();
}
private static string FormatCode(long error)
{
int code = GetCode(error);
return code.ToString();
}
public override void ExecuteCommand()
{
if (Parameters.Equals(String.Empty))
{
Say("Please provide an Error Code.");
return;
}
string errorText = Parameters;
retry:
NumberParser np = new NumberParser();
long error = np.Parse(errorText);
if (np.Error)
{
Say("{0} is not a valid Error Code.", Parameters);
return;
}
ArrayList descriptions = new ArrayList();
// Error is out of bounds
if ((ulong)error > uint.MaxValue)
{
// Do nothing
}
// Error is outside of the range [0, 65535]: it cannot be a plain Win32 error code
else if ((ulong)error > ushort.MaxValue)
{
// Customer bit is set: custom error code
if (IsCustomer(error))
{
string description = String.Format("[custom, severity {0}, facility {1}, code {2}]",
FormatSeverity(error),
FormatFacility(error),
FormatCode(error));
descriptions.Add(description);
}
// Reserved bit is set: HRESULT_FROM_NT(ntstatus)
else if (IsReserved(error))
{
int status = (int)(error & 0xCFFFFFFF);
string description = ntStatus.GetNtstatusDescription(status);
if (description == null)
description = status.ToString("X");
description = String.Format("HRESULT_FROM_NT({0})", description);
descriptions.Add(description);
}
// Win32 facility: HRESULT_FROM_WIN32(winerror)
else if (GetFacility(error) == 7)
{
// Must be an error code
if (GetSeverity(error) == 2)
{
short err = GetCode(error);
string description = winerror.GetWinerrorDescription(err);
if (description == null)
description = err.ToString("D");
description = String.Format("HRESULT_FROM_WIN32({0})", description);
descriptions.Add(description);
}
}
}
string winerrorDescription = winerror.GetWinerrorDescription(error);
string ntstatusDescription = ntStatus.GetNtstatusDescription(error);
string hresultDescription = hresult.GetHresultDescription(error);
if (winerrorDescription != null)
descriptions.Add(winerrorDescription);
if (ntstatusDescription != null)
descriptions.Add(ntstatusDescription);
if (hresultDescription != null)
descriptions.Add(hresultDescription);
if (descriptions.Count == 0)
{
// Last chance heuristics: attempt to parse a 8-digit decimal as hexadecimal
if (errorText.Length == 8)
{
errorText = "0x" + errorText;
goto retry;
}
Say("I don't know about Error Code {0}.",
Parameters);
}
else if (descriptions.Count == 1)
{
string description = (string)descriptions[0];
Say("{0} is {1}.",
Parameters,
description);
}
else
{
Say("{0} could be:", Parameters);
foreach (string description in descriptions)
Say("\t{0}", description);
}
}
}
}

View File

@@ -1,66 +0,0 @@
using System;
using System.Xml;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("hresult", Help = "!hresult <value>")]
public class HResultCommand : XmlLookupCommand
{
public HResultCommand()
{
}
public override string XmlFile
{
get { return Settings.Default.HResultXml; }
}
public override void ExecuteCommand()
{
if (string.IsNullOrEmpty(Text))
{
Say("Please provide a valid HRESULT value.");
}
else
{
NumberParser np = new NumberParser();
long hresult = np.Parse(Text);
if (np.Error)
{
Say("{0} is not a valid HRESULT value.", Text);
return;
}
string description = GetHresultDescription(hresult);
if (description != null)
{
Say("{0} is {1}.",
Text,
description);
}
else
{
Say("I don't know about HRESULT {0}.", Text);
}
}
}
public string GetHresultDescription(long hresult)
{
XmlElement root = base.m_XmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
hresult.ToString("X8")));
if (node != null)
{
XmlAttribute text = node.Attributes["text"];
if (text == null)
throw new Exception("Node has no text attribute.");
return text.Value;
}
else
return null;
}
}
}

View File

@@ -1,66 +0,0 @@
using System;
using System.Xml;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("ntstatus", Help = "!ntstatus <value>")]
public class NtStatusCommand : XmlLookupCommand
{
public NtStatusCommand()
{
}
public override string XmlFile
{
get { return Settings.Default.NtStatusXml; }
}
public override void ExecuteCommand()
{
if (string.IsNullOrEmpty(Text))
{
Say("Please provide a valid NTSTATUS value.");
}
else
{
NumberParser np = new NumberParser();
long ntstatus = np.Parse(Text);
if (np.Error)
{
Say("{0} is not a valid NTSTATUS value.", Text);
return;
}
string description = GetNtstatusDescription(ntstatus);
if (description != null)
{
Say("{0} is {1}.",
Text,
description);
}
else
{
Say("I don't know about NTSTATUS {0}.", Text);
}
}
}
public string GetNtstatusDescription(long ntstatus)
{
XmlElement root = base.m_XmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
ntstatus.ToString("X8")));
if (node != null)
{
XmlAttribute text = node.Attributes["text"];
if (text == null)
throw new Exception("Node has no text attribute.");
return text.Value;
}
else
return null;
}
}
}

View File

@@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TechBot.Commands.Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sand")]
[assembly: AssemblyProduct("TechBot.Commands.Common")]
[assembly: AssemblyCopyright("Copyright © Sand 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5d39d6f8-37fb-423b-ba88-1d5d8e5a1317")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("rosbug", Help = "!rosbug <number>", Description = "Will give you a link to the reqested ReactOS bug")]
class ReactOSBugUrl : BugCommand
{
public ReactOSBugUrl()
{
}
protected override string BugUrl
{
get { return "http://www.reactos.org/bugzilla/show_bug.cgi?id={0}"; }
}
}
}

View File

@@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("sambabug", Help = "!sambabug <number>", Description = "Will give you a link to the reqested Samba bug")]
class SambaBugUrl : BugCommand
{
public SambaBugUrl()
{
}
protected override string BugUrl
{
get { return "https://bugzilla.samba.org/show_bug.cgi?id={0}"; }
}
}
}

View File

@@ -1,71 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TechBot.Commands.Common {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")]
public string NtStatusXml {
get {
return ((string)(this["NtStatusXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")]
public string WinErrorXml {
get {
return ((string)(this["WinErrorXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")]
public string HResultXml {
get {
return ((string)(this["HResultXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")]
public string WMXml {
get {
return ((string)(this["WMXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/reactos/trunk")]
public string SVNRoot {
get {
return ((string)(this["SVNRoot"]));
}
}
}
}

View File

@@ -1,28 +0,0 @@
namespace TechBot.Commands.Common {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View File

@@ -1,21 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Commands.Common" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="NtStatusXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</Value>
</Setting>
<Setting Name="WinErrorXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\winerror.xml</Value>
</Setting>
<Setting Name="HResultXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\hresult.xml</Value>
</Setting>
<Setting Name="WMXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\wm.xml</Value>
</Setting>
<Setting Name="SVNRoot" Type="System.String" Scope="Application">
<Value Profile="(Default)">svn://svn.reactos.org/reactos/trunk</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -1,22 +0,0 @@
using System;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("svn", Help = "!svn" , Description="Where the ROS SVN repository is located")]
public class SvnCommand : Command
{
private string m_SvnRoot;
public SvnCommand()
{
m_SvnRoot = Settings.Default.SVNRoot;
}
public override void ExecuteCommand()
{
Say("svn co {0}", m_SvnRoot);
}
}
}

View File

@@ -1,75 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechBot.Commands.Common</RootNamespace>
<AssemblyName>TechBot.Commands.Common</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Base\BugCommand.cs" />
<Compile Include="ErrorCommand.cs" />
<Compile Include="HResultCommand.cs" />
<Compile Include="NtStatusCommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReactOSBugUrl.cs" />
<Compile Include="SambaBugUrl.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Settings.Designer.cs">
<DependentUpon>Settings.settings</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="SvnCommand.cs" />
<Compile Include="WineBugUrl.cs" />
<Compile Include="WinerrorCommand.cs" />
<Compile Include="WMCommand.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
<Name>TechBot.Library</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,94 +0,0 @@
using System;
using System.Xml;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("wm" , Help = "!wm <value> or !wm <name>")]
public class WMCommand : XmlCommand
{
public WMCommand()
{
}
public override string XmlFile
{
get { return Settings.Default.WMXml; }
}
[CommandParameter("wm", "The windows message to check" , DefaultParameter = true)]
public string WMText
{
get { return Parameters; }
set { Parameters = value; }
}
public override void ExecuteCommand()
{
if (string.IsNullOrEmpty(WMText))
{
Say("Please provide a valid window message value or name.");
}
else
{
NumberParser np = new NumberParser();
long wm = np.Parse(WMText);
string output;
if (np.Error)
{
// Assume "!wm <name>" form.
output = GetWmNumber(WMText);
}
else
{
output = GetWmDescription(wm);
}
if (output != null)
{
Say("{0} is {1}.",
WMText,
output);
}
else
{
Say("I don't know about window message {0}.", WMText);
}
}
}
private string GetWmDescription(long wm)
{
XmlElement root = base.m_XmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
wm));
if (node != null)
{
XmlAttribute text = node.Attributes["text"];
if (text == null)
throw new Exception("Node has no text attribute.");
return text.Value;
}
else
return null;
}
private string GetWmNumber(string wmName)
{
XmlElement root = base.m_XmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
wmName));
if (node != null)
{
XmlAttribute value = node.Attributes["value"];
if (value == null)
throw new Exception("Node has no value attribute.");
return value.Value;
}
else
return null;
}
}
}

View File

@@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("winebug", Help = "!winebug <number>" , Description="Will give you a link to the reqested Wine bug")]
class WineBugUrl : BugCommand
{
public WineBugUrl()
{
}
protected override string BugUrl
{
get { return "http://bugs.winehq.org/show_bug.cgi?id={0}"; }
}
}
}

View File

@@ -1,66 +0,0 @@
using System;
using System.Xml;
using TechBot.Library;
namespace TechBot.Commands.Common
{
[Command("winerror", Help = "!winerror <value>")]
public class WinErrorCommand : XmlLookupCommand
{
public WinErrorCommand()
{
}
public override string XmlFile
{
get { return Settings.Default.WinErrorXml; }
}
public override void ExecuteCommand()
{
if (string.IsNullOrEmpty(Text))
{
Say("Please provide a valid System Error Code value.");
}
else
{
NumberParser np = new NumberParser();
long winerror = np.Parse(Text);
if (np.Error)
{
Say("{0} is not a valid System Error Code value.", Text);
return;
}
string description = GetWinerrorDescription(winerror);
if (description != null)
{
Say("{0} is {1}.",
Text,
description);
}
else
{
Say("I don't know about System Error Code {0}.", Text);
}
}
}
public string GetWinerrorDescription(long winerror)
{
XmlElement root = base.m_XmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
winerror.ToString()));
if (node != null)
{
XmlAttribute text = node.Attributes["text"];
if (text == null)
throw new Exception("Node has no text attribute.");
return text.Value;
}
else
return null;
}
}
}

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TechBot.Commands.Common.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<TechBot.Commands.Common.Settings>
<setting name="NtStatusXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</value>
</setting>
<setting name="WinErrorXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\winerror.xml</value>
</setting>
<setting name="HResultXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\hresult.xml</value>
</setting>
<setting name="WMXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\wm.xml</value>
</setting>
<setting name="SVNRoot" serializeAs="String">
<value>svn://svn.reactos.org/reactos/trunk</value>
</setting>
</TechBot.Commands.Common.Settings>
</applicationSettings>
</configuration>

View File

@@ -1,309 +0,0 @@
using System;
using System.IO;
using System.Data;
using System.Text.RegularExpressions;
using HtmlHelp;
using HtmlHelp.ChmDecoding;
using TechBot.Library;
namespace TechBot.Commands.MSDN
{
[Command("api", Help = "!api <apiname>")]
public class ApiCommand : Command
{
private bool IsVerbose = false;
private HtmlHelpSystem chm;
public ApiCommand()
{
LoadCHM();
}
[CommandParameter("api", "The API name")]
public string API
{
get { return Parameters; }
set { Parameters = value; }
}
private void WriteIfVerbose(string message)
{
if (IsVerbose)
Say(message);
}
private void LoadCHM()
{
string CHMFilename = Path.Combine(Settings.Default.ChmPath, Settings.Default.MainChm);
chm = new HtmlHelpSystem();
chm.OpenFile(CHMFilename, null);
Console.WriteLine(String.Format("Loaded main CHM: {0}",
Path.GetFileName(CHMFilename)));
foreach (string filename in Directory.GetFiles(Settings.Default.ChmPath))
{
if (!Path.GetExtension(filename).ToLower().Equals(".chm"))
continue;
if (Path.GetFileName(filename).ToLower().Equals(Settings.Default.MainChm))
continue;
Console.WriteLine(String.Format("Loading CHM: {0}",
Path.GetFileName(filename)));
try
{
chm.MergeFile(filename);
}
catch (Exception ex)
{
Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}",
Path.GetFileName(filename),
ex));
}
}
Console.WriteLine(String.Format("Loaded {0} CHMs",
chm.FileList.Length));
}
public override void ExecuteCommand()
{
if (Name.Trim().Equals(String.Empty))
{
Say("Please give me a keyword.");
}
else
{
Search(Name);
}
}
private bool SearchIndex(
string keyword)
{
if (chm.HasIndex)
{
IndexItem item = chm.Index.SearchIndex(keyword,
IndexType.KeywordLinks);
if (item != null && item.Topics.Count > 0)
{
WriteIfVerbose(String.Format("Keyword {0} found in index",
item.KeyWord));
IndexTopic indexTopic = item.Topics[0] as IndexTopic;
return DisplayResult( keyword,
indexTopic);
}
else
{
WriteIfVerbose(String.Format("Keyword {0} not found in index",
keyword));
return false;
}
}
else
return false;
}
private void SearchFullText(string keyword)
{
string sort = "Rating ASC";
WriteIfVerbose(String.Format("Searching fulltext database for {0}",
keyword));
bool partialMatches = false;
bool titlesOnly = true;
int maxResults = 100;
DataTable results = chm.PerformSearch(keyword,
maxResults,
partialMatches,
titlesOnly);
WriteIfVerbose(String.Format("results.Rows.Count = {0}",
results != null ?
results.Rows.Count.ToString() : "(none)"));
if (results != null && results.Rows.Count > 0)
{
results.DefaultView.Sort = sort;
if (!DisplayResult(keyword,
results))
{
Say("No result");
}
}
else
{
Say("No result");
}
}
private void Search(string keyword)
{
if (!SearchIndex(keyword))
SearchFullText(keyword);
}
private bool DisplayResult(string keyword,
IndexTopic indexTopic)
{
keyword = keyword.Trim().ToLower();
string url = indexTopic.URL;
WriteIfVerbose(String.Format("URL from index search {0}",
url));
string prototype = ExtractPrototype(url);
if (prototype == null || prototype.Trim().Equals(String.Empty))
return false;
string formattedPrototype = FormatPrototype(prototype);
Say(formattedPrototype);
return true;
}
private bool DisplayResult(string keyword,
DataTable results)
{
keyword = keyword.Trim().ToLower();
for (int i = 0; i < results.DefaultView.Count; i++)
{
DataRowView row = results.DefaultView[i];
string title = row["Title"].ToString();
WriteIfVerbose(String.Format("Examining {0}", title));
if (title.Trim().ToLower().Equals(keyword))
{
string location = row["Location"].ToString();
string rating = row["Rating"].ToString();
string url = row["Url"].ToString();
string prototype = ExtractPrototype(url);
if (prototype == null || prototype.Trim().Equals(String.Empty))
continue;
string formattedPrototype = FormatPrototype(prototype);
Say(formattedPrototype);
return true;
}
}
return false;
}
private void DisplayNoResult(MessageContext context,
string keyword)
{
TechBot.ServiceOutput.WriteLine(context,
String.Format("I don't know about keyword {0}",
keyword));
}
private string ReplaceComments(string s)
{
return Regex.Replace(s, "//(.+)\r\n", "");
}
private string ReplaceLineEndings(string s)
{
return Regex.Replace(s, "(\r\n)+", " ");
}
private string ReplaceSpaces(string s)
{
return Regex.Replace(s, @" +", " ");
}
private string ReplaceSpacesBeforeLeftParenthesis(string s)
{
return Regex.Replace(s, @"\( ", @"(");
}
private string ReplaceSpacesBeforeRightParenthesis(string s)
{
return Regex.Replace(s, @" \)", @")");
}
private string ReplaceSemicolon(string s)
{
return Regex.Replace(s, @";", @"");
}
private string FormatPrototype(string prototype)
{
string s = ReplaceComments(prototype);
s = ReplaceLineEndings(s);
s = ReplaceSpaces(s);
s = ReplaceSpacesBeforeLeftParenthesis(s);
s = ReplaceSpacesBeforeRightParenthesis(s);
s = ReplaceSemicolon(s);
return s;
}
private string ExtractPrototype(string url)
{
string page = GetPage(url);
Match match = Regex.Match(page,
"<PRE class=\"?syntax\"?>(.+)</PRE>",
RegexOptions.Multiline |
RegexOptions.Singleline);
if (match.Groups.Count > 1)
{
string prototype = match.Groups[1].ToString();
return StripHtml(StripAfterSlashPre(prototype));
}
return "";
}
private string StripAfterSlashPre(string html)
{
int index = html.IndexOf("</PRE>");
if (index != -1)
{
return html.Substring(0, index);
}
else
return html;
}
private string StripHtml(string html)
{
return Regex.Replace(html, @"<(.|\n)*?>", String.Empty);
}
private string GetPage(string url)
{
string CHMFileName = "";
string topicName = "";
string anchor = "";
CHMStream.CHMStream baseStream;
if (!chm.BaseStream.GetCHMParts(url, ref CHMFileName, ref topicName, ref anchor))
{
baseStream = chm.BaseStream;
CHMFileName = baseStream.CHMFileName;
topicName = url;
anchor = "";
}
else
{
baseStream = GetBaseStreamFromCHMFileName(CHMFileName);
}
if ((topicName == "") || (CHMFileName == "") || (baseStream == null))
{
return "";
}
return baseStream.ExtractTextFile(topicName);
}
private CHMStream.CHMStream GetBaseStreamFromCHMFileName(string CHMFileName)
{
foreach (CHMFile file in chm.FileList)
{
WriteIfVerbose(String.Format("Compare: {0} <> {1}",
file.ChmFilePath,
CHMFileName));
if (file.ChmFilePath.ToLower().Equals(CHMFileName.ToLower()))
{
return file.BaseStream;
}
}
WriteIfVerbose(String.Format("Could not find loaded CHM file in list: {0}",
CHMFileName));
return null;
}
}
}

View File

@@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TechBot.Commands.MSDN")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sand")]
[assembly: AssemblyProduct("TechBot.Commands.MSDN")]
[assembly: AssemblyCopyright("Copyright © Sand 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8a6332ce-82e3-4fbd-a799-8f4b8d025955")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,50 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TechBot.Commands.MSDN {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\IRC\\TechBot\\CHM")]
public string ChmPath {
get {
return ((string)(this["ChmPath"]));
}
set {
this["ChmPath"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("kmarch.chm")]
public string MainChm {
get {
return ((string)(this["MainChm"]));
}
set {
this["MainChm"] = value;
}
}
}
}

View File

@@ -1,12 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Commands.MSDN" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ChmPath" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\IRC\TechBot\CHM</Value>
</Setting>
<Setting Name="MainChm" Type="System.String" Scope="User">
<Value Profile="(Default)">kmarch.chm</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -1,69 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechBot.Commands.MSDN</RootNamespace>
<AssemblyName>TechBot.Commands.MSDN</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ApiCommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CHMLibrary\CHMLibrary.csproj">
<Project>{72E5CCA1-6318-4D62-964D-CB23A5C743B5}</Project>
<Name>CHMLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
<Name>TechBot.Library</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,5 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TechBot.Commands.MSDN.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<TechBot.Commands.MSDN.Settings>
<setting name="ChmPath" serializeAs="String">
<value>C:\IRC\TechBot\CHM</value>
</setting>
<setting name="MainChm" serializeAs="String">
<value>kmarch.chm</value>
</setting>
</TechBot.Commands.MSDN.Settings>
</userSettings>
</configuration>

View File

@@ -1,27 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TechBot.Console.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<TechBot.Console.Settings>
<setting name="IRCServerHostName" serializeAs="String">
<value>irc.eu.freenode.net</value>
</setting>
<setting name="IRCChannelNames" serializeAs="String">
<value>rbuildbottest2</value>
</setting>
<setting name="IRCBotName" serializeAs="String">
<value>RBuildBot2</value>
</setting>
<setting name="IRCBotPassword" serializeAs="String">
<value>qwerty</value>
</setting>
<setting name="IRCServerHostPort" serializeAs="String">
<value>6667</value>
</setting>
</TechBot.Console.Settings>
</userSettings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="IRCServerHostName" value="irc.eu.freenode.net" />
<add key="IRCServerHostPort" value="6667" />
<add key="IRCChannelNames" value="channel1;channel2" />
<add key="IRCBotName" value="MyBot" />
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
<add key="MainChm" value="kmarch.chm" />
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
<add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
<add key="SvnCommand" value="svn co svn://svn.reactos.com/trunk/reactos" />
</appSettings>
</configuration>

View File

@@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using TechBot.Library;
namespace TechBot.Console
{
public class ConsoleServiceOutput : IServiceOutput
{
public void WriteLine(MessageContext context,
string message)
{
System.Console.WriteLine(message);
}
}
public class ConsoleTechBotService : TechBotService
{
public ConsoleTechBotService()
: base(new ConsoleServiceOutput())
{
System.Console.WriteLine("TechBot running console service...");
}
public override void Run()
{
//Call the base class
base.Run();
while (true)
{
InjectMessage(System.Console.ReadLine());
}
}
}
}

View File

@@ -1,29 +1,189 @@
using System;
using System.Configuration;
using TechBot.Library;
namespace TechBot.Console
{
class MainClass
{
public static void Main(string[] args)
{
TechBotService m_TechBot = null;
if (args.Length > 0 && args[0].ToLower().Equals("irc"))
{
m_TechBot = new IrcTechBotService(Settings.Default.IRCServerHostName,
Settings.Default.IRCServerHostPort,
Settings.Default.IRCChannelNames,
Settings.Default.IRCBotName,
Settings.Default.IRCBotPassword);
}
else
{
m_TechBot = new ConsoleTechBotService();
}
m_TechBot.Run();
}
}
}
using System;
using System.Configuration;
using TechBot.Library;
namespace TechBot.Console
{
public class ConsoleServiceOutput : IServiceOutput
{
public void WriteLine(MessageContext context,
string message)
{
System.Console.WriteLine(message);
}
}
class MainClass
{
private static void VerifyRequiredOption(string optionName,
string optionValue)
{
if (optionValue == null)
{
throw new Exception(String.Format("Option '{0}' not set.",
optionName));
}
}
private static string IRCServerHostName
{
get
{
string optionName = "IRCServerHostName";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static int IRCServerHostPort
{
get
{
string optionName = "IRCServerHostPort";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return Int32.Parse(s);
}
}
private static string IRCChannelNames
{
get
{
string optionName = "IRCChannelNames";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static string IRCBotName
{
get
{
string optionName = "IRCBotName";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static string ChmPath
{
get
{
string optionName = "ChmPath";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static string MainChm
{
get
{
string optionName = "MainChm";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static string NtstatusXml
{
get
{
string optionName = "NtstatusXml";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static string WinerrorXml
{
get
{
string optionName = "WinerrorXml";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static string HresultXml
{
get
{
string optionName = "HresultXml";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static string SvnCommand
{
get
{
string optionName = "SvnCommand";
string s = ConfigurationSettings.AppSettings[optionName];
VerifyRequiredOption(optionName,
s);
return s;
}
}
private static void RunIrcService()
{
IrcService ircService = new IrcService(IRCServerHostName,
IRCServerHostPort,
IRCChannelNames,
IRCBotName,
ChmPath,
MainChm,
NtstatusXml,
WinerrorXml,
HresultXml,
SvnCommand);
ircService.Run();
}
public static void Main(string[] args)
{
if (args.Length > 0 && args[0].ToLower().Equals("irc"))
{
RunIrcService();
return;
}
System.Console.WriteLine("TechBot running console service...");
TechBotService service = new TechBotService(new ConsoleServiceOutput(),
ChmPath,
MainChm,
NtstatusXml,
WinerrorXml,
HresultXml,
SvnCommand);
service.Run();
while (true)
{
string s = System.Console.ReadLine();
service.InjectMessage(null,
s);
}
}
}
}

View File

@@ -1,86 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TechBot.Console {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")]
public string IRCServerHostName {
get {
return ((string)(this["IRCServerHostName"]));
}
set {
this["IRCServerHostName"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest2")]
public string IRCChannelNames {
get {
return ((string)(this["IRCChannelNames"]));
}
set {
this["IRCChannelNames"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("RBuildBot2")]
public string IRCBotName {
get {
return ((string)(this["IRCBotName"]));
}
set {
this["IRCBotName"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("qwerty")]
public string IRCBotPassword {
get {
return ((string)(this["IRCBotPassword"]));
}
set {
this["IRCBotPassword"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("6667")]
public int IRCServerHostPort {
get {
return ((int)(this["IRCServerHostPort"]));
}
set {
this["IRCServerHostPort"] = value;
}
}
}
}

View File

@@ -1,21 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Console" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="IRCServerHostName" Type="System.String" Scope="User">
<Value Profile="(Default)">irc.eu.freenode.net</Value>
</Setting>
<Setting Name="IRCChannelNames" Type="System.String" Scope="User">
<Value Profile="(Default)">rbuildbottest2</Value>
</Setting>
<Setting Name="IRCBotName" Type="System.String" Scope="User">
<Value Profile="(Default)">RBuildBot2</Value>
</Setting>
<Setting Name="IRCBotPassword" Type="System.String" Scope="User">
<Value Profile="(Default)">qwerty</Value>
</Setting>
<Setting Name="IRCServerHostPort" Type="System.Int32" Scope="User">
<Value Profile="(Default)">6667</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -1,80 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechBot.Console</RootNamespace>
<AssemblyName>TechBot.Console</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="ConsoleTechBotService.cs" />
<Compile Include="Main.cs" />
<Compile Include="Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TechBot.Commands.Common\TechBot.Commands.Common.csproj">
<Project>{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}</Project>
<Name>TechBot.Commands.Common</Name>
</ProjectReference>
<ProjectReference Include="..\TechBot.Commands.RBuild\TechBot.Commands.RBuild.csproj">
<Project>{D676FEDE-62DD-4B4D-94C6-308598E827F9}</Project>
<Name>TechBot.Commands.RBuild</Name>
</ProjectReference>
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
<Name>TechBot.IRCLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
<Name>TechBot.Library</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

View File

@@ -16,13 +16,9 @@ namespace TechBot.IRCLibrary
public const string PONG = "PONG";
public const string PRIVMSG = "PRIVMSG";
public const string USER = "USER";
public const string PASS = "PASS";
public const string GHOST = "NICKSERV GHOST";
public const string NOTICE = "NOTICE";
public const string RPL_NAMREPLY = "353";
public const string RPL_ENDOFNAMES = "366";
public const string ERR_NICKNAMEINUSE = "433";
#endregion

View File

@@ -16,10 +16,6 @@ namespace TechBot.IRCLibrary
/// </summary>
public delegate void ChannelUserDatabaseChangedHandler(IrcChannel channel);
public delegate void OnConnectHandler ();
public delegate void OnDisconnectHandler();
public delegate void OnConnectionLostHandler();
/// <summary>
/// An IRC client.
/// </summary>
@@ -191,7 +187,6 @@ namespace TechBot.IRCLibrary
#region Private fields
private bool firstPingReceived = false;
private bool awaitingGhostDeath = false;
private System.Text.Encoding encoding = System.Text.Encoding.UTF8;
private TcpClient tcpClient;
private NetworkStream networkStream;
@@ -199,9 +194,6 @@ namespace TechBot.IRCLibrary
private LineBuffer messageStream;
private ArrayList ircCommandEventRegistrations = new ArrayList();
private ArrayList channels = new ArrayList();
private string reqNickname;
private string curNickname;
private string password;
#endregion
#region Public events
@@ -210,10 +202,6 @@ namespace TechBot.IRCLibrary
public event ChannelUserDatabaseChangedHandler ChannelUserDatabaseChanged;
public event OnConnectHandler OnConnect;
public event OnConnectionLostHandler OnConnectionLost;
public event OnDisconnectHandler OnDisconnect;
#endregion
#region Public properties
@@ -244,16 +232,6 @@ namespace TechBot.IRCLibrary
}
}
/// <summary>
/// Nickname for the bot.
/// </summary>
public string Nickname
{
get
{
return curNickname;
}
}
#endregion
#region Private methods
@@ -313,39 +291,20 @@ namespace TechBot.IRCLibrary
/// <param name="ar">IAsyncResult object.</param>
private void ReadComplete(IAsyncResult ar)
{
try
{
StateObject stateObject = (StateObject)ar.AsyncState;
if (stateObject.Stream.CanRead)
{
int bytesReceived = stateObject.Stream.EndRead(ar);
if (bytesReceived > 0)
{
messageStream.Write(Encoding.GetString(stateObject.Buffer, 0, bytesReceived));
while (messageStream.DataAvailable)
{
OnMessageReceived(new IrcMessage(messageStream.Read()));
}
}
}
Receive();
}
catch (SocketException)
{
if (OnConnectionLost != null)
OnConnectionLost();
}
catch (IOException)
{
if (OnConnectionLost != null)
OnConnectionLost();
}
catch (Exception)
{
if (OnConnectionLost != null)
OnConnectionLost();
}
StateObject stateObject = (StateObject) ar.AsyncState;
if (stateObject.Stream.CanRead)
{
int bytesReceived = stateObject.Stream.EndRead(ar);
if (bytesReceived > 0)
{
messageStream.Write(Encoding.GetString(stateObject.Buffer, 0, bytesReceived));
while (messageStream.DataAvailable)
{
OnMessageReceived(new IrcMessage(messageStream.Read()));
}
}
}
Receive();
}
/// <summary>
@@ -375,24 +334,6 @@ namespace TechBot.IRCLibrary
firstPingReceived = true;
}
/// <summary>
/// Send a PONG message when a PING message is received.
/// </summary>
/// <param name="message">Received IRC message.</param>
private void NoticeMessageReceived(IrcMessage message)
{
if (awaitingGhostDeath)
{
string str = string.Format("{0} has been ghosted", reqNickname);
if (message.Parameters.Contains(str))
{
ChangeNick(reqNickname);
SubmitPassword(password);
awaitingGhostDeath = false;
}
}
}
/// <summary>
/// Process RPL_NAMREPLY message.
/// </summary>
@@ -504,31 +445,6 @@ namespace TechBot.IRCLibrary
}
}
/// <summary>
/// Process ERR_NICKNAMEINUSE message.
/// </summary>
/// <param name="message">Received IRC message.</param>
private void ERR_NICKNAMEINUSEMessageReceived(IrcMessage message)
{
try
{
if (message.Parameters == null)
{
System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters."));
return;
}
/* Connect with a different name */
string[] parameters = message.Parameters.Split(new char[] { ' ' });
string nickname = parameters[1];
ChangeNick(nickname + "__");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex));
}
}
#endregion
/// <summary>
@@ -557,14 +473,10 @@ namespace TechBot.IRCLibrary
}
/* Install PING message handler */
MonitorCommand(IRC.PING, new MessageReceivedHandler(PingMessageReceived));
/* Install NOTICE message handler */
MonitorCommand(IRC.NOTICE, new MessageReceivedHandler(NoticeMessageReceived));
/* Install RPL_NAMREPLY message handler */
MonitorCommand(IRC.RPL_NAMREPLY, new MessageReceivedHandler(RPL_NAMREPLYMessageReceived));
/* Install RPL_ENDOFNAMES message handler */
MonitorCommand(IRC.RPL_ENDOFNAMES, new MessageReceivedHandler(RPL_ENDOFNAMESMessageReceived));
/* Install ERR_NICKNAMEINUSE message handler */
MonitorCommand(IRC.ERR_NICKNAMEINUSE, new MessageReceivedHandler(ERR_NICKNAMEINUSEMessageReceived));
/* Start receiving data */
Receive();
}
@@ -581,12 +493,11 @@ namespace TechBot.IRCLibrary
}
else
{
connected = false;
tcpClient.Close();
tcpClient = null;
if (OnDisconnect != null)
OnDisconnect();
}
}
@@ -596,37 +507,19 @@ namespace TechBot.IRCLibrary
/// <param name="message">The message to be sent.</param>
public void SendMessage(IrcMessage message)
{
try
{
if (!connected)
{
throw new NotConnectedException();
}
/* Serialize sending messages */
lock (typeof(IrcClient))
{
NetworkStream networkStream = tcpClient.GetStream();
byte[] bytes = Encoding.GetBytes(message.Line);
networkStream.Write(bytes, 0, bytes.Length);
networkStream.Flush();
}
}
catch (SocketException)
{
if (OnConnectionLost != null)
OnConnectionLost();
}
catch (IOException)
{
if (OnConnectionLost != null)
OnConnectionLost();
}
catch (Exception)
{
if (OnConnectionLost != null)
OnConnectionLost();
}
if (!connected)
{
throw new NotConnectedException();
}
/* Serialize sending messages */
lock (typeof(IrcClient))
{
NetworkStream networkStream = tcpClient.GetStream();
byte[] bytes = Encoding.GetBytes(message.Line);
networkStream.Write(bytes, 0, bytes.Length);
networkStream.Flush();
}
}
/// <summary>
@@ -663,67 +556,26 @@ namespace TechBot.IRCLibrary
public void ChangeNick(string nickname)
{
if (nickname == null)
{
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
Console.WriteLine("Changing nick to {0}\n", nickname);
curNickname = nickname;
}
/* NICK <nickname> [ <hopcount> ] */
SendMessage(new IrcMessage(IRC.NICK, nickname));
}
/// <summary>
/// Ghost nickname.
/// </summary>
/// <param name="nickname">Nickname.</param>
public void GhostNick(string nickname,
string password)
{
if (nickname == null)
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
if (password == null)
throw new ArgumentNullException("password", "Password cannot be null.");
awaitingGhostDeath = true;
/* GHOST <nickname> <password> */
SendMessage(new IrcMessage(IRC.GHOST, nickname + " " + password));
}
/// <summary>
/// Submit password to identify user.
/// </summary>
/// <param name="password">Password of registered nick.</param>
private void SubmitPassword(string password)
{
if (password == null)
throw new ArgumentNullException("password", "Password cannot be null.");
this.password = password;
/* PASS <password> */
SendMessage(new IrcMessage(IRC.PASS, password));
}
/// <summary>
/// Register.
/// </summary>
/// <param name="nickname">New nickname.</param>
/// <param name="password">Password. Can be null.</param>
/// <param name="realname">Real name. Can be null.</param>
public void Register(string nickname,
string password,
string realname)
public void Register(string nickname, string realname)
{
if (nickname == null)
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
reqNickname = nickname;
firstPingReceived = false;
if (password != null)
{
SubmitPassword(password);
throw new ArgumentNullException("nickname", "Nickname cannot be null.");
}
firstPingReceived = false;
ChangeNick(nickname);
/* OLD: USER <username> <hostname> <servername> <realname> */
/* NEW: USER <user> <mode> <unused> <realname> */

View File

@@ -419,7 +419,7 @@ namespace TechBot.IRCLibrary
{
foreach (char c in command)
{
if (!Char.IsLetter(c) && !Char.IsWhiteSpace(c))
if (!Char.IsLetter(c))
{
return false;
}

View File

@@ -1,59 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechBot.IRCLibrary</RootNamespace>
<AssemblyName>TechBot.IRCLibrary</AssemblyName>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="IRC.cs" />
<Compile Include="IrcChannel.cs" />
<Compile Include="IrcClient.cs" />
<Compile Include="IrcException.cs" />
<Compile Include="IrcMessage.cs" />
<Compile Include="IrcUser.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TechBot.IRCLibrary.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<TechBot.IRCLibrary.Settings>
<setting name="CommandPrefix" serializeAs="String">
<value>!</value>
</setting>
</TechBot.IRCLibrary.Settings>
</userSettings>
</configuration>

View File

@@ -0,0 +1,351 @@
using System;
using System.IO;
using System.Data;
using System.Text.RegularExpressions;
using HtmlHelp;
using HtmlHelp.ChmDecoding;
namespace TechBot.Library
{
public class ApiCommand : BaseCommand, ICommand
{
private const bool IsVerbose = false;
private HtmlHelpSystem chm;
private IServiceOutput serviceOutput;
private string chmPath;
private string mainChm;
public ApiCommand(IServiceOutput serviceOutput,
string chmPath,
string mainChm)
{
this.serviceOutput = serviceOutput;
this.chmPath = chmPath;
this.mainChm = mainChm;
Run();
}
private void WriteIfVerbose(MessageContext context,
string message)
{
if (IsVerbose)
serviceOutput.WriteLine(context,
message);
}
private void Run()
{
string CHMFilename = Path.Combine(chmPath, mainChm);
chm = new HtmlHelpSystem();
chm.OpenFile(CHMFilename, null);
Console.WriteLine(String.Format("Loaded main CHM: {0}",
Path.GetFileName(CHMFilename)));
foreach (string filename in Directory.GetFiles(chmPath))
{
if (!Path.GetExtension(filename).ToLower().Equals(".chm"))
continue;
if (Path.GetFileName(filename).ToLower().Equals(mainChm))
continue;
Console.WriteLine(String.Format("Loading CHM: {0}",
Path.GetFileName(filename)));
try
{
chm.MergeFile(filename);
}
catch (Exception ex)
{
Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}",
Path.GetFileName(filename),
ex));
}
}
Console.WriteLine(String.Format("Loaded {0} CHMs",
chm.FileList.Length));
}
public bool CanHandle(string commandName)
{
return CanHandle(commandName,
new string[] { "api" });
}
public void Handle(MessageContext context,
string commandName,
string parameters)
{
if (parameters.Trim().Equals(String.Empty))
DisplayNoKeyword(context);
else
Search(context,
parameters);
}
public string Help()
{
return "!api <apiname>";
}
private bool SearchIndex(MessageContext context,
string keyword)
{
if (chm.HasIndex)
{
IndexItem item = chm.Index.SearchIndex(keyword,
IndexType.KeywordLinks);
if (item != null && item.Topics.Count > 0)
{
WriteIfVerbose(context,
String.Format("Keyword {0} found in index",
item.KeyWord));
IndexTopic indexTopic = item.Topics[0] as IndexTopic;
return DisplayResult(context,
keyword,
indexTopic);
}
else
{
WriteIfVerbose(context,
String.Format("Keyword {0} not found in index",
keyword));
return false;
}
}
else
return false;
}
private void SearchFullText(MessageContext context,
string keyword)
{
string sort = "Rating ASC";
WriteIfVerbose(context,
String.Format("Searching fulltext database for {0}",
keyword));
bool partialMatches = false;
bool titlesOnly = true;
int maxResults = 100;
DataTable results = chm.PerformSearch(keyword,
maxResults,
partialMatches,
titlesOnly);
WriteIfVerbose(context,
String.Format("results.Rows.Count = {0}",
results != null ?
results.Rows.Count.ToString() : "(none)"));
if (results != null && results.Rows.Count > 0)
{
results.DefaultView.Sort = sort;
if (!DisplayResult(context,
keyword,
results))
{
DisplayNoResult(context,
keyword);
}
}
else
{
DisplayNoResult(context,
keyword);
}
}
private void Search(MessageContext context,
string keyword)
{
if (!SearchIndex(context,
keyword))
SearchFullText(context,
keyword);
}
private bool DisplayResult(MessageContext context,
string keyword,
IndexTopic indexTopic)
{
keyword = keyword.Trim().ToLower();
string url = indexTopic.URL;
WriteIfVerbose(context,
String.Format("URL from index search {0}",
url));
string prototype = ExtractPrototype(context,
url);
if (prototype == null || prototype.Trim().Equals(String.Empty))
return false;
string formattedPrototype = FormatPrototype(prototype);
serviceOutput.WriteLine(context,
formattedPrototype);
return true;
}
private bool DisplayResult(MessageContext context,
string keyword,
DataTable results)
{
keyword = keyword.Trim().ToLower();
for (int i = 0; i < results.DefaultView.Count; i++)
{
DataRowView row = results.DefaultView[i];
string title = row["Title"].ToString();
WriteIfVerbose(context,
String.Format("Examining {0}", title));
if (title.Trim().ToLower().Equals(keyword))
{
string location = row["Location"].ToString();
string rating = row["Rating"].ToString();
string url = row["Url"].ToString();
string prototype = ExtractPrototype(context,
url);
if (prototype == null || prototype.Trim().Equals(String.Empty))
continue;
string formattedPrototype = FormatPrototype(prototype);
serviceOutput.WriteLine(context,
formattedPrototype);
return true;
}
}
return false;
}
private void DisplayNoResult(MessageContext context,
string keyword)
{
serviceOutput.WriteLine(context,
String.Format("I don't know about keyword {0}",
keyword));
}
private void DisplayNoKeyword(MessageContext context)
{
serviceOutput.WriteLine(context,
"Please give me a keyword.");
}
private string ReplaceComments(string s)
{
return Regex.Replace(s, "//(.+)\r\n", "");
}
private string ReplaceLineEndings(string s)
{
return Regex.Replace(s, "(\r\n)+", " ");
}
private string ReplaceSpaces(string s)
{
return Regex.Replace(s, @" +", " ");
}
private string ReplaceSpacesBeforeLeftParenthesis(string s)
{
return Regex.Replace(s, @"\( ", @"(");
}
private string ReplaceSpacesBeforeRightParenthesis(string s)
{
return Regex.Replace(s, @" \)", @")");
}
private string ReplaceSemicolon(string s)
{
return Regex.Replace(s, @";", @"");
}
private string FormatPrototype(string prototype)
{
string s = ReplaceComments(prototype);
s = ReplaceLineEndings(s);
s = ReplaceSpaces(s);
s = ReplaceSpacesBeforeLeftParenthesis(s);
s = ReplaceSpacesBeforeRightParenthesis(s);
s = ReplaceSemicolon(s);
return s;
}
private string ExtractPrototype(MessageContext context,
string url)
{
string page = GetPage(context,
url);
Match match = Regex.Match(page,
"<PRE class=\"?syntax\"?>(.+)</PRE>",
RegexOptions.Multiline |
RegexOptions.Singleline);
if (match.Groups.Count > 1)
{
string prototype = match.Groups[1].ToString();
return StripHtml(StripAfterSlashPre(prototype));
}
return "";
}
private string StripAfterSlashPre(string html)
{
int index = html.IndexOf("</PRE>");
if (index != -1)
{
return html.Substring(0, index);
}
else
return html;
}
private string StripHtml(string html)
{
return Regex.Replace(html, @"<(.|\n)*?>", String.Empty);
}
private string GetPage(MessageContext context,
string url)
{
string CHMFileName = "";
string topicName = "";
string anchor = "";
CHMStream.CHMStream baseStream;
if (!chm.BaseStream.GetCHMParts(url, ref CHMFileName, ref topicName, ref anchor))
{
baseStream = chm.BaseStream;
CHMFileName = baseStream.CHMFileName;
topicName = url;
anchor = "";
}
else
{
baseStream = GetBaseStreamFromCHMFileName(context,
CHMFileName);
}
if ((topicName == "") || (CHMFileName == "") || (baseStream == null))
{
return "";
}
return baseStream.ExtractTextFile(topicName);
}
private CHMStream.CHMStream GetBaseStreamFromCHMFileName(MessageContext context,
string CHMFileName)
{
foreach (CHMFile file in chm.FileList)
{
WriteIfVerbose(context,
String.Format("Compare: {0} <> {1}",
file.ChmFilePath,
CHMFileName));
if (file.ChmFilePath.ToLower().Equals(CHMFileName.ToLower()))
{
return file.BaseStream;
}
}
WriteIfVerbose(context,
String.Format("Could not find loaded CHM file in list: {0}",
CHMFileName));
return null;
}
}
}

View File

@@ -0,0 +1,32 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]
// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
// This is not required, if you don't want signing let these attributes like they're.
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]

View File

@@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace TechBot.Library
{
public class CommandAttribute : Attribute
{
private string m_Name = null;
private string m_Help = "No help for this command is available";
private string m_Desc = "No description for this command is available";
public CommandAttribute(string name)
{
m_Name = name;
}
public string Name
{
get { return m_Name; }
}
public string Help
{
get { return m_Help; }
set { m_Help = value; }
}
public string Description
{
get { return m_Desc; }
set { m_Desc = value; }
}
}
}

View File

@@ -1,34 +0,0 @@
using System;
namespace TechBot.Library
{
/// <summary>
/// This class implements an alias attribute to work in conjunction
/// with the <see cref="CommandLineSwitchAttribute">CommandLineSwitchAttribute</see>
/// attribute. If the CommandLineSwitchAttribute exists, then this attribute
/// defines an alias for it.
/// </summary>
[AttributeUsage( AttributeTargets.Property )]
public class CommandParameterAliasAttribute : Attribute
{
#region Private Variables
protected string m_Alias = "";
#endregion
#region Public Properties
public string Alias
{
get { return m_Alias; }
}
#endregion
#region Constructors
public CommandParameterAliasAttribute(string alias)
{
m_Alias = alias;
}
#endregion
}
}

View File

@@ -1,50 +0,0 @@
using System;
namespace TechBot.Library
{
/// <summary>Implements a basic command-line switch by taking the
/// switching name and the associated description.</summary>
/// <remark>Only currently is implemented for properties, so all
/// auto-switching variables should have a get/set method supplied.</remark>
[AttributeUsage( AttributeTargets.Property )]
public class CommandParameterAttribute : Attribute
{
#region Private Variables
private string m_name = "";
private string m_description = "";
private bool m_Required = true;
private bool m_Default = false;
#endregion
#region Public Properties
/// <summary>Accessor for retrieving the switch-name for an associated
/// property.</summary>
public string Name { get { return m_name; } }
/// <summary>Accessor for retrieving the description for a switch of
/// an associated property.</summary>
public string Description { get { return m_description; } }
public bool Required { get { return m_Required; } }
public bool DefaultParameter
{
get { return m_Default; }
set { m_Default = value; }
}
#endregion
#region Constructors
/// <summary>
/// Attribute constructor.
/// </summary>
public CommandParameterAttribute(string name, string description)
{
m_name = name;
m_description = description;
}
#endregion
}
}

View File

@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace TechBot.Library
{
public class CommandBuilderCollection : List<CommandBuilder>
{
public CommandBuilder Find(string name)
{
foreach (CommandBuilder command in this)
{
if (command.Name == name)
return command;
}
return null;
}
}
}

View File

@@ -1,90 +0,0 @@
using System;
using System.Text.RegularExpressions;
namespace TechBot.Library
{
public abstract class Command
{
protected TechBotService m_TechBotService = null;
protected MessageContext m_Context = null;
protected string m_Params = null;
public TechBotService TechBot
{
get { return m_TechBotService; }
set { m_TechBotService = value; }
}
public MessageContext Context
{
get { return m_Context; }
set { m_Context = value; }
}
public virtual bool AnswerInPublic
{
get { return true; }
}
public string Name
{
get
{
CommandAttribute commandAttribute = (CommandAttribute)
Attribute.GetCustomAttribute(GetType(), typeof(CommandAttribute));
return commandAttribute.Name;
}
}
public string Parameters
{
get { return m_Params; }
set { m_Params = value; }
}
protected virtual void Say()
{
TechBot.ServiceOutput.WriteLine(Context, string.Empty);
}
protected virtual void Say(string message)
{
TechBot.ServiceOutput.WriteLine(Context, message);
}
protected virtual void Say(string format , params object[] args)
{
TechBot.ServiceOutput.WriteLine(Context, String.Format(format, args));
}
public void Run()
{
if (Context is ChannelMessageContext)
{
if (AnswerInPublic)
{
ExecuteCommand();
}
else
{
Say("Sorry, I only respond '{0}' in private , PM me!", Name);
}
}
else
{
ExecuteCommand();
}
}
public abstract void ExecuteCommand();
public virtual void Initialize()
{
}
public virtual void DeInitialize()
{
}
}
}

View File

@@ -1,25 +0,0 @@
using System;
using System.Xml;
using System.Collections.Generic;
using System.Text;
namespace TechBot.Library
{
public abstract class XmlCommand : Command
{
protected XmlDocument m_XmlDocument;
public XmlCommand()
{
m_XmlDocument = new XmlDocument();
m_XmlDocument.Load(XmlFile);
}
public abstract string XmlFile { get; }
public XmlDocument XmlDocument
{
get { return m_XmlDocument; }
}
}
}

View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace TechBot.Library
{
public abstract class XmlLookupCommand : XmlCommand
{
public virtual string Text
{
get { return Parameters; }
set { Parameters = value; }
}
}
}

View File

@@ -1,78 +0,0 @@
using System;
using System.Reflection;
using System.Collections;
namespace TechBot.Library
{
[Command("help", Help = "!help or !help -name:[CommandName]", Description = "Shows this help , type 'help -name:[CommandName]'")]
public class HelpCommand : Command
{
public HelpCommand()
{
}
public override bool AnswerInPublic
{
get { return false; }
}
[CommandParameter("Name", "The command name to show help")]
public string CommandName
{
get { return Parameters; }
set { Parameters = value; }
}
public override void ExecuteCommand()
{
if (string.IsNullOrEmpty(CommandName))
{
Say("I support the following commands:");
foreach (CommandBuilder command in TechBot.Commands)
{
Say("{0}{1} - {2}",
Settings.Default.CommandPrefix,
command.Name,
command.Description);
}
}
else
{
CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName);
if (cmdBuilder == null)
{
Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName);
}
else
{
Say("Command '{0}' help:", CommandName);
Say();
Say(cmdBuilder.Description);
Say();
Say(cmdBuilder.Help);
Say();
Say("Parameters :");
Say();
PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo propertyInfo in propertyInfoArray)
{
CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[])
Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute));
foreach (CommandParameterAttribute parameter in commandAttributes)
{
Say("\t-{0}: [{1}]",
parameter.Name,
parameter.Description);
}
}
Say();
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<project name="TechBot.Library" default="build">
<property name="output.dir" value="..\bin" />
<target name="build" description="Build component">
<mkdir dir="${output.dir}" />
<csc target="library"
output="${output.dir}\TechBot.Library.dll"
optimize="true"
debug="true"
doc="${output.dir}\TechBot.Library.xml"
warninglevel="0">
<sources>
<include name="*.cs" />
</sources>
<references>
<include name="${output.dir}\CHMLibrary.dll" />
<include name="${output.dir}\TechBot.IRCLibrary.dll" />
</references>
</csc>
</target>
</project>

View File

@@ -1,52 +0,0 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
namespace TechBot.Library
{
public class CommandBuilder
{
private Type m_CommandType;
private string m_CommandName;
private string m_CommandHelp;
private string m_CommandDesc;
public CommandBuilder(Type commandType)
{
m_CommandType = commandType;
CommandAttribute commandAttribute = (CommandAttribute)
Attribute.GetCustomAttribute(commandType, typeof(CommandAttribute));
m_CommandName = commandAttribute.Name;
m_CommandHelp = commandAttribute.Help;
m_CommandDesc = commandAttribute.Description;
}
public string Name
{
get { return m_CommandName; }
}
public string Help
{
get { return m_CommandHelp; }
}
public string Description
{
get { return m_CommandDesc; }
}
public Type Type
{
get { return m_CommandType; }
}
public Command CreateCommand()
{
return (Command)Type.Assembly.CreateInstance(Type.FullName, true);
}
}
}

View File

@@ -1,60 +0,0 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
namespace TechBot.Library
{
public class CommandFactory
{
private static CommandBuilderCollection m_Commands = new CommandBuilderCollection();
private CommandFactory()
{
}
public static void LoadPlugins()
{
//get the file names of the dll files in the current directory.
foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "*.dll"))
{
LoadPluginsFromDLLFile(fileName);
}
}
private static void LoadPluginsFromDLLFile(string sFile)
{
Assembly assPlugin = Assembly.LoadFile(sFile);
Console.WriteLine("Loading plugins from : {0}", assPlugin.Location);
if (assPlugin != null)
{
foreach (Type pluginType in assPlugin.GetTypes())
{
if (pluginType.IsSubclassOf(typeof(Command)))
{
if (pluginType.IsAbstract == false)
{
CommandBuilder cmdBuilder = new CommandBuilder(pluginType);
Console.WriteLine("{0}:{1}",
cmdBuilder.Name,
cmdBuilder.Description);
//Add it to the list.
Commands.Add(new CommandBuilder(pluginType));
}
}
}
}
}
public static CommandBuilderCollection Commands
{
get { return m_Commands; }
}
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections;
namespace TechBot.Library
{
public class HelpCommand : BaseCommand, ICommand
{
private IServiceOutput serviceOutput;
private ArrayList commands;
public HelpCommand(IServiceOutput serviceOutput,
ArrayList commands)
{
this.serviceOutput = serviceOutput;
this.commands = commands;
}
public bool CanHandle(string commandName)
{
return CanHandle(commandName,
new string[] { "help" });
}
public void Handle(MessageContext context,
string commandName,
string parameters)
{
serviceOutput.WriteLine(context,
"I support the following commands:");
foreach (ICommand command in commands)
{
serviceOutput.WriteLine(context,
command.Help());
}
}
public string Help()
{
return "!help";
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Xml;
namespace TechBot.Library
{
public class HresultCommand : BaseCommand, ICommand
{
private IServiceOutput serviceOutput;
private string hresultXml;
private XmlDocument hresultXmlDocument;
public HresultCommand(IServiceOutput serviceOutput,
string hresultXml)
{
this.serviceOutput = serviceOutput;
this.hresultXml = hresultXml;
hresultXmlDocument = new XmlDocument();
hresultXmlDocument.Load(hresultXml);
}
public bool CanHandle(string commandName)
{
return CanHandle(commandName,
new string[] { "hresult" });
}
public void Handle(MessageContext context,
string commandName,
string parameters)
{
string hresultText = parameters;
if (hresultText.Equals(String.Empty))
{
serviceOutput.WriteLine(context,
"Please provide a valid HRESULT value.");
return;
}
NumberParser np = new NumberParser();
long hresult = np.Parse(hresultText);
if (np.Error)
{
serviceOutput.WriteLine(context,
String.Format("{0} is not a valid HRESULT value.",
hresultText));
return;
}
string description = GetHresultDescription(hresult);
if (description != null)
{
serviceOutput.WriteLine(context,
String.Format("{0} is {1}.",
hresultText,
description));
}
else
{
serviceOutput.WriteLine(context,
String.Format("I don't know about HRESULT {0}.",
hresultText));
}
}
public string Help()
{
return "!hresult <value>";
}
private string GetHresultDescription(long hresult)
{
XmlElement root = hresultXmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']",
hresult.ToString("X8")));
if (node != null)
{
XmlAttribute text = node.Attributes["text"];
if (text == null)
throw new Exception("Node has no text attribute.");
return text.Value;
}
else
return null;
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
namespace TechBot.Library
{
public interface ICommand
{
bool CanHandle(string commandName);
void Handle(MessageContext context,
string commandName,
string parameters);
string Help();
}
public class BaseCommand
{
protected bool CanHandle(string commandName,
string[] availableCommands)
{
foreach (string availableCommand in availableCommands)
{
if (String.Compare(availableCommand, commandName, true) == 0)
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,273 @@
using System;
using System.Collections;
using System.Threading;
using TechBot.IRCLibrary;
namespace TechBot.Library
{
public class IrcService : IServiceOutput
{
private string hostname;
private int port;
private string channelnames;
private string botname;
private string chmPath;
private string mainChm;
private string ntstatusXml;
private string winerrorXml;
private string hresultXml;
private string svnCommand;
private IrcClient client;
private ArrayList channels = new ArrayList(); /* IrcChannel */
private TechBotService service;
private bool isStopped = false;
public IrcService(string hostname,
int port,
string channelnames,
string botname,
string chmPath,
string mainChm,
string ntstatusXml,
string winerrorXml,
string hresultXml,
string svnCommand)
{
this.hostname = hostname;
this.port = port;
this.channelnames = channelnames;
this.botname = botname;
this.chmPath = chmPath;
this.mainChm = mainChm;
this.ntstatusXml = ntstatusXml;
this.winerrorXml = winerrorXml;
this.hresultXml = hresultXml;
this.svnCommand = svnCommand;
}
public void Run()
{
service = new TechBotService(this,
chmPath,
mainChm,
ntstatusXml,
winerrorXml,
hresultXml,
svnCommand);
service.Run();
client = new IrcClient();
client.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1");
client.MessageReceived += new MessageReceivedHandler(client_MessageReceived);
client.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);
System.Console.WriteLine(String.Format("Connecting to {0} port {1}",
hostname, port));
client.Connect(hostname, port);
System.Console.WriteLine("Connected...");
client.Register(botname, null);
System.Console.WriteLine(String.Format("Registered as {0}...", botname));
JoinChannels();
while (!isStopped)
{
Thread.Sleep(1000);
}
PartChannels();
client.Diconnect();
System.Console.WriteLine("Disconnected...");
}
public void Stop()
{
isStopped = true;
}
private void JoinChannels()
{
foreach (string channelname in channelnames.Split(new char[] { ';' }))
{
IrcChannel channel = client.JoinChannel(channelname);
channels.Add(channel);
System.Console.WriteLine(String.Format("Joined channel #{0}...",
channel.Name));
}
}
private void PartChannels()
{
foreach (IrcChannel channel in channels)
{
client.PartChannel(channel, "Caught in the bitstream...");
System.Console.WriteLine(String.Format("Parted channel #{0}...",
channel.Name));
}
}
private string GetMessageSource(MessageContext context)
{
if (context is ChannelMessageContext)
{
ChannelMessageContext channelContext = context as ChannelMessageContext;
return String.Format("#{0}",
channelContext.Channel.Name);
}
else if (context is UserMessageContext)
{
UserMessageContext userContext = context as UserMessageContext;
return userContext.User.Nickname;
}
else
{
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
context.GetType()));
}
}
public void WriteLine(MessageContext context,
string message)
{
if (context is ChannelMessageContext)
{
ChannelMessageContext channelContext = context as ChannelMessageContext;
channelContext.Channel.Talk(message);
}
else if (context is UserMessageContext)
{
UserMessageContext userContext = context as UserMessageContext;
userContext.User.Talk(message);
}
else
{
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
context.GetType()));
}
}
private void ExtractMessage(string parameters,
out string message)
{
int startIndex = parameters.IndexOf(':');
if (startIndex != -1)
{
message = parameters.Substring(startIndex + 1);
}
else
{
message = parameters;
}
}
private bool GetChannelName(IrcMessage message,
out string channelName)
{
if (message.Parameters == null || !message.Parameters.StartsWith("#"))
{
channelName = null;
return false;
}
int index = message.Parameters.IndexOf(' ');
if (index == -1)
index = message.Parameters.Length;
else
index = index - 1;
channelName = message.Parameters.Substring(1, index);
return true;
}
private bool GetTargetNickname(IrcMessage message,
out string nickname)
{
if (message.Parameters == null)
{
nickname = null;
return false;
}
int index = message.Parameters.IndexOf(' ');
if (index == -1)
index = message.Parameters.Length;
nickname = message.Parameters.Substring(0, index);
Console.WriteLine("nickname: " + nickname);
return true;
}
private bool ShouldAcceptMessage(IrcMessage message,
out MessageContext context)
{
if (message.Command.ToUpper().Equals("PRIVMSG"))
{
string channelName;
string nickname;
if (GetChannelName(message,
out channelName))
{
foreach (IrcChannel channel in channels)
{
if (String.Compare(channel.Name, channelName, true) == 0)
{
context = new ChannelMessageContext(channel);
return true;
}
}
}
else if (GetTargetNickname(message,
out nickname))
{
IrcUser targetUser = new IrcUser(client,
nickname);
if (String.Compare(targetUser.Nickname, botname, true) == 0)
{
IrcUser sourceUser = new IrcUser(client,
message.PrefixNickname);
context = new UserMessageContext(sourceUser);
return true;
}
}
}
context = null;
return false;
}
private void client_MessageReceived(IrcMessage message)
{
try
{
if (message.Command != null &&
message.Parameters != null)
{
string injectMessage;
ExtractMessage(message.Parameters,
out injectMessage);
MessageContext context;
if (ShouldAcceptMessage(message,
out context))
{
Console.WriteLine(String.Format("Injecting: {0} from {1}",
injectMessage,
GetMessageSource(context)));
service.InjectMessage(context,
injectMessage);
}
else
{
Console.WriteLine("Received: " + message.Line);
}
}
else
{
Console.WriteLine("Received: " + message.Line);
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("Exception: {0}", ex));
}
}
private void client_ChannelUserDatabaseChanged(IrcChannel channel)
{
}
}
}

View File

@@ -7,33 +7,43 @@ namespace TechBot.Library
{
}
public class ChannelMessageContext : MessageContext
{
private IrcChannel m_IrcChannel;
private IrcChannel channel;
public IrcChannel Channel
{
get { return m_IrcChannel; }
}
public IrcChannel Channel
{
get
{
return channel;
}
}
public ChannelMessageContext(IrcChannel channel)
{
m_IrcChannel = channel;
this.channel = channel;
}
}
public class UserMessageContext : MessageContext
{
private IrcUser m_IrcUser;
private IrcUser user;
public IrcUser User
{
get { return m_IrcUser; }
}
public IrcUser User
{
get
{
return user;
}
}
public UserMessageContext(IrcUser user)
{
m_IrcUser = user;
this.user = user;
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Xml;
namespace TechBot.Library
{
public class NtStatusCommand : BaseCommand, ICommand
{
private IServiceOutput serviceOutput;
private string ntstatusXml;
private XmlDocument ntstatusXmlDocument;
public NtStatusCommand(IServiceOutput serviceOutput,
string ntstatusXml)
{
this.serviceOutput = serviceOutput;
this.ntstatusXml = ntstatusXml;
ntstatusXmlDocument = new XmlDocument();
ntstatusXmlDocument.Load(ntstatusXml);
}
public bool CanHandle(string commandName)
{
return CanHandle(commandName,
new string[] { "ntstatus" });
}
public void Handle(MessageContext context,
string commandName,
string parameters)
{
string ntstatusText = parameters;
if (ntstatusText.Equals(String.Empty))
{
serviceOutput.WriteLine(context,
"Please provide a valid NTSTATUS value.");
return;
}
NumberParser np = new NumberParser();
long ntstatus = np.Parse(ntstatusText);
if (np.Error)
{
serviceOutput.WriteLine(context,
String.Format("{0} is not a valid NTSTATUS value.",
ntstatusText));
return;
}
string description = GetNtstatusDescription(ntstatus);
if (description != null)
{
serviceOutput.WriteLine(context,
String.Format("{0} is {1}.",
ntstatusText,
description));
}
else
{
serviceOutput.WriteLine(context,
String.Format("I don't know about NTSTATUS {0}.",
ntstatusText));
}
}
public string Help()
{
return "!ntstatus <value>";
}
private string GetNtstatusDescription(long ntstatus)
{
XmlElement root = ntstatusXmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']",
ntstatus.ToString("X8")));
if (node != null)
{
XmlAttribute text = node.Attributes["text"];
if (text == null)
throw new Exception("Node has no text attribute.");
return text.Value;
}
else
return null;
}
}
}

View File

@@ -9,7 +9,7 @@ namespace TechBot.Library
private const string SpecialHexCharacters = "ABCDEF";
private static bool IsSpecialHexCharacter(char ch)
private bool IsSpecialHexCharacter(char ch)
{
foreach (char specialChar in SpecialHexCharacters)
{
@@ -19,7 +19,7 @@ namespace TechBot.Library
return false;
}
private static bool HasSpecialHexCharacters(string s)
private bool HasSpecialHexCharacters(string s)
{
foreach (char ch in s)
{
@@ -35,7 +35,7 @@ namespace TechBot.Library
{
Error = false;
bool useHex = false;
if (s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
if (s.StartsWith("0x"))
{
s = s.Substring(2);
useHex = true;

View File

@@ -1,32 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]
// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
// This is not required, if you don't want signing let these attributes like they're.
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]

View File

@@ -2,8 +2,9 @@ using System;
namespace TechBot.Library
{
public interface IServiceOutput
{
void WriteLine(MessageContext context, string message);
}
public interface IServiceOutput
{
void WriteLine(MessageContext context,
string message);
}
}

View File

@@ -1,80 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TechBot.Library {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")]
public string NtStatusXml {
get {
return ((string)(this["NtStatusXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")]
public string WinErrorXml {
get {
return ((string)(this["WinErrorXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")]
public string HResultXml {
get {
return ((string)(this["HResultXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")]
public string WMXml {
get {
return ((string)(this["WMXml"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/reactos/trunk")]
public string SVNRoot {
get {
return ((string)(this["SVNRoot"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("!")]
public string CommandPrefix {
get {
return ((string)(this["CommandPrefix"]));
}
}
}
}

View File

@@ -1,28 +0,0 @@
namespace TechBot.Library {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View File

@@ -1,24 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot.Library" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="NtStatusXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</Value>
</Setting>
<Setting Name="WinErrorXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\winerror.xml</Value>
</Setting>
<Setting Name="HResultXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\hresult.xml</Value>
</Setting>
<Setting Name="WMXml" Type="System.String" Scope="Application">
<Value Profile="(Default)">C:\Ros\current\irc\TechBot\Resources\wm.xml</Value>
</Setting>
<Setting Name="SVNRoot" Type="System.String" Scope="Application">
<Value Profile="(Default)">svn://svn.reactos.org/reactos/trunk</Value>
</Setting>
<Setting Name="CommandPrefix" Type="System.String" Scope="Application">
<Value Profile="(Default)">!</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,36 @@
using System;
namespace TechBot.Library
{
public class SvnCommand : BaseCommand, ICommand
{
private IServiceOutput serviceOutput;
private string svnCommand;
public SvnCommand(IServiceOutput serviceOutput,
string svnCommand)
{
this.serviceOutput = serviceOutput;
this.svnCommand = svnCommand;
}
public bool CanHandle(string commandName)
{
return CanHandle(commandName,
new string[] { "svn" });
}
public void Handle(MessageContext context,
string commandName,
string parameters)
{
serviceOutput.WriteLine(context,
svnCommand);
}
public string Help()
{
return "!svn";
}
}
}

View File

@@ -0,0 +1,16 @@
<Combine fileversion="1.0" name="TechBot.Library" description="">
<StartMode startupentry="TechBot.Library" single="True">
<Execute entry="TechBot.Library" type="None" />
</StartMode>
<Entries>
<Entry filename=".\.\TechBot.Library.prjx" />
</Entries>
<Configurations active="Debug">
<Configuration name="Release">
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
</Configuration>
<Configuration name="Debug">
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
</Configuration>
</Configurations>
</Combine>

View File

@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechBot.Library</RootNamespace>
<AssemblyName>TechBot.Library</AssemblyName>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="Attributes\CommandAttribute.cs" />
<Compile Include="Attributes\CommandParameterAliasAttribute.cs" />
<Compile Include="Attributes\CommandParameterAttribute.cs" />
<Compile Include="Collections\CommandBuilderCollection.cs" />
<Compile Include="Commands\Base\XmlLookupCommand.cs" />
<Compile Include="Factory\CommandBuilder.cs" />
<Compile Include="Factory\CommandFactory.cs" />
<Compile Include="Commands\Base\Command.cs" />
<Compile Include="Commands\Base\XmlCommand.cs" />
<Compile Include="Commands\HelpCommand.cs" />
<Compile Include="MessageContext.cs" />
<Compile Include="NumberParser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServiceOutput.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="TechBotIrcService.cs" />
<Compile Include="TechBotService.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
<Name>TechBot.IRCLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,39 @@
<Project name="TechBot.Library" standardNamespace="TechBot.Library" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">
<Contents>
<File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\Default.build" subtype="Code" buildaction="Nothing" dependson="" data="" />
<File name=".\TechBotService.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\ServiceOutput.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\IrcService.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\ApiCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\ICommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\HelpCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\NtStatusCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\NumberParser.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\HresultCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\WinerrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\SvnCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
</Contents>
<References>
<Reference type="Project" refto="CHMLibrary" localcopy="True" />
<Reference type="Project" refto="TechBot.IRCLibrary" localcopy="True" />
</References>
<DeploymentInformation target="" script="" strategy="File" />
<Configuration runwithwarnings="True" name="Debug">
<CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
<Execution commandlineparameters="" consolepause="False" />
<Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
</Configuration>
<Configurations active="Debug">
<Configuration runwithwarnings="True" name="Debug">
<CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
<Execution commandlineparameters="" consolepause="False" />
<Output directory="..\bin\Debug" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
</Configuration>
<Configuration runwithwarnings="True" name="Release">
<CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
<Execution commandlineparameters="" consolepause="False" />
<Output directory="..\bin\Release" assembly="TechBot.Library" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
</Configuration>
</Configurations>
</Project>

View File

@@ -1,312 +0,0 @@
using System;
using System.Text;
using System.Collections;
using System.Threading;
using TechBot.IRCLibrary;
namespace TechBot.Library
{
public class IrcServiceOutput : IServiceOutput
{
public void WriteLine(MessageContext context,
string message)
{
if (context is ChannelMessageContext)
{
Thread.Sleep (500);
ChannelMessageContext channelContext = context as ChannelMessageContext;
channelContext.Channel.Talk(message);
}
else if (context is UserMessageContext)
{
UserMessageContext userContext = context as UserMessageContext;
userContext.User.Talk(message);
}
else
{
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
context.GetType()));
}
}
}
public class IrcTechBotService : TechBotService
{
private int port;
private string hostname;
private string channelnames;
private string botname;
private string password;
private IrcClient m_IrcClient;
private ArrayList channels = new ArrayList();
private bool isStopped = false;
public IrcTechBotService(string hostname,
int port,
string channelnames,
string botname,
string password)
: base (new IrcServiceOutput())
{
this.hostname = hostname;
this.port = port;
this.channelnames = channelnames;
this.botname = botname;
if (password == null || password.Trim() == "")
this.password = null;
else
this.password = password;
}
public override void Run()
{
//Call the base class
base.Run();
m_IrcClient = new IrcClient();
m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1");
m_IrcClient.OnConnect += new OnConnectHandler(m_IrcClient_OnConnect);
m_IrcClient.OnConnectionLost += new OnConnectionLostHandler(m_IrcClient_OnConnectionLost);
m_IrcClient.OnDisconnect += new OnDisconnectHandler(m_IrcClient_OnDisconnect);
m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived);
m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged);
Connect();
}
void m_IrcClient_OnConnect()
{
Console.WriteLine("Connected...");
}
private void Connect()
{
Console.WriteLine("Connecting to {0} port {1}",
hostname,
port);
m_IrcClient.Connect(hostname, port);
m_IrcClient.Register(botname, password, null);
Console.WriteLine("Registered as {0}...", m_IrcClient.Nickname);
/* Did we get the nick we wanted? */
if (m_IrcClient.Nickname != botname)
{
/* there must have been an existing one, kill it */
m_IrcClient.GhostNick(botname, password);;
}
JoinChannels();
while (!isStopped)
{
Thread.Sleep(1000);
}
PartChannels();
m_IrcClient.Diconnect();
}
void m_IrcClient_OnDisconnect()
{
Console.WriteLine("Disconnected...");
}
void m_IrcClient_OnConnectionLost()
{
//Dispose old connection
Disconnect();
//Sleep for 1 minute
Thread.Sleep(1000 * 60);
//Try to reconnect
Connect();
}
private void Disconnect()
{
try
{
m_IrcClient.Diconnect();
}
catch (Exception)
{
//
}
}
public void Stop()
{
isStopped = true;
}
private void JoinChannels()
{
foreach (string channelname in channelnames.Split(new char[] { ';' }))
{
IrcChannel channel = m_IrcClient.JoinChannel(channelname);
channels.Add(channel);
System.Console.WriteLine(String.Format("Joined channel #{0}...",
channel.Name));
}
}
private void PartChannels()
{
foreach (IrcChannel channel in channels)
{
m_IrcClient.PartChannel(channel, "Caught in the bitstream...");
System.Console.WriteLine(String.Format("Parted channel #{0}...",
channel.Name));
}
}
private string GetMessageSource(MessageContext context)
{
if (context is ChannelMessageContext)
{
ChannelMessageContext channelContext = context as ChannelMessageContext;
return String.Format("#{0}",
channelContext.Channel.Name);
}
else if (context is UserMessageContext)
{
UserMessageContext userContext = context as UserMessageContext;
return userContext.User.Nickname;
}
else
{
throw new InvalidOperationException(String.Format("Unhandled message context '{0}'",
context.GetType()));
}
}
private void ExtractMessage(string parameters,
out string message)
{
int startIndex = parameters.IndexOf(':');
if (startIndex != -1)
{
message = parameters.Substring(startIndex + 1);
}
else
{
message = parameters;
}
}
private bool GetChannelName(IrcMessage message,
out string channelName)
{
if (message.Parameters == null || !message.Parameters.StartsWith("#"))
{
channelName = null;
return false;
}
int index = message.Parameters.IndexOf(' ');
if (index == -1)
index = message.Parameters.Length;
else
index = index - 1;
channelName = message.Parameters.Substring(1, index);
return true;
}
private bool GetTargetNickname(IrcMessage message,
out string nickname)
{
if (message.Parameters == null)
{
nickname = null;
return false;
}
int index = message.Parameters.IndexOf(' ');
if (index == -1)
index = message.Parameters.Length;
nickname = message.Parameters.Substring(0, index);
Console.WriteLine("nickname: " + nickname);
return true;
}
private bool ShouldAcceptMessage(IrcMessage message,
out MessageContext context)
{
if (message.Command.ToUpper().Equals("PRIVMSG"))
{
string channelName;
string nickname;
if (GetChannelName(message,
out channelName))
{
foreach (IrcChannel channel in channels)
{
if (String.Compare(channel.Name, channelName, true) == 0)
{
context = new ChannelMessageContext(channel);
return true;
}
}
}
else if (GetTargetNickname(message,
out nickname))
{
IrcUser targetUser = new IrcUser(m_IrcClient,
nickname);
if (String.Compare(targetUser.Nickname, botname, true) == 0)
{
IrcUser sourceUser = new IrcUser(m_IrcClient,
message.PrefixNickname);
context = new UserMessageContext(sourceUser);
return true;
}
}
}
context = null;
return false;
}
private void client_MessageReceived(IrcMessage message)
{
try
{
if (message.Command != null &&
message.Parameters != null)
{
string injectMessage;
ExtractMessage(message.Parameters,
out injectMessage);
MessageContext context;
if (ShouldAcceptMessage(message,
out context))
{
Console.WriteLine(String.Format("Injecting: {0} from {1}",
injectMessage,
GetMessageSource(context)));
InjectMessage(context,
injectMessage);
}
else
{
Console.WriteLine("Received: " + message.Line);
}
}
else
{
Console.WriteLine("Received: " + message.Line);
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("Exception: {0}", ex));
}
}
private void client_ChannelUserDatabaseChanged(IrcChannel channel)
{
}
}
}

View File

@@ -1,101 +1,97 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Data;
using System.Threading;
using TechBot.IRCLibrary;
namespace TechBot.Library
{
public abstract class TechBotService
{
protected IServiceOutput m_ServiceOutput;
public TechBotService(IServiceOutput serviceOutput)
{
m_ServiceOutput = serviceOutput;
}
public virtual void Run()
{
CommandFactory.LoadPlugins();
}
public IServiceOutput ServiceOutput
{
get { return m_ServiceOutput; }
}
public CommandBuilderCollection Commands
{
get { return CommandFactory.Commands; }
}
public void InjectMessage(MessageContext context, string message)
{
ParseCommandMessage(context,
message);
}
private bool IsCommandMessage(string message)
{
return message.StartsWith(Settings.Default.CommandPrefix);
}
public void InjectMessage(string message)
{
ParseCommandMessage(null, message);
}
public void ParseCommandMessage(MessageContext context,
string message)
{
if (!IsCommandMessage(message))
return;
message = message.Substring(1).Trim();
int index = message.IndexOf(' ');
string commandName;
string commandParams = "";
if (index != -1)
{
commandName = message.Substring(0, index).Trim();
commandParams = message.Substring(index).Trim();
}
else
commandName = message.Trim();
foreach (CommandBuilder command in Commands)
{
if (command.Name == commandName)
{
//Create a new instance of the required command type
Command cmd = command.CreateCommand();
cmd.TechBot = this;
cmd.Context = context;
cmd.Parameters = commandParams;
try
{
cmd.Initialize();
cmd.Run();
cmd.DeInitialize();
}
catch (Exception e)
{
ServiceOutput.WriteLine(context, string.Format("Uops! Just crashed with exception '{0}' at {1}",
e.Message,
e.Source));
ServiceOutput.WriteLine(context, e.StackTrace);
}
return;
}
}
}
}
}
using System;
using System.Collections;
using System.IO;
using System.Data;
using System.Threading;
using TechBot.IRCLibrary;
namespace TechBot.Library
{
public class TechBotService
{
private IServiceOutput serviceOutput;
private string chmPath;
private string mainChm;
private string ntstatusXml;
private string winerrorXml;
private string hresultXml;
private string svnCommand;
private ArrayList commands = new ArrayList();
public TechBotService(IServiceOutput serviceOutput,
string chmPath,
string mainChm,
string ntstatusXml,
string winerrorXml,
string hresultXml,
string svnCommand)
{
this.serviceOutput = serviceOutput;
this.chmPath = chmPath;
this.mainChm = mainChm;
this.ntstatusXml = ntstatusXml;
this.winerrorXml = winerrorXml;
this.hresultXml = hresultXml;
this.svnCommand = svnCommand;
}
public void Run()
{
commands.Add(new HelpCommand(serviceOutput,
commands));
commands.Add(new ApiCommand(serviceOutput,
chmPath,
mainChm));
commands.Add(new NtStatusCommand(serviceOutput,
ntstatusXml));
commands.Add(new WinerrorCommand(serviceOutput,
winerrorXml));
commands.Add(new HresultCommand(serviceOutput,
hresultXml));
commands.Add(new SvnCommand(serviceOutput,
svnCommand));
}
public void InjectMessage(MessageContext context,
string message)
{
if (message.StartsWith("!"))
ParseCommandMessage(context,
message);
}
private bool IsCommandMessage(string message)
{
return message.StartsWith("!");
}
public void ParseCommandMessage(MessageContext context,
string message)
{
if (!IsCommandMessage(message))
return;
message = message.Substring(1).Trim();
int index = message.IndexOf(' ');
string commandName;
string parameters = "";
if (index != -1)
{
commandName = message.Substring(0, index).Trim();
parameters = message.Substring(index).Trim();
}
else
commandName = message.Trim();
foreach (ICommand command in commands)
{
if (command.CanHandle(commandName))
{
command.Handle(context,
commandName, parameters);
return;
}
}
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Xml;
namespace TechBot.Library
{
public class WinerrorCommand : BaseCommand, ICommand
{
private IServiceOutput serviceOutput;
private string winerrorXml;
private XmlDocument winerrorXmlDocument;
public WinerrorCommand(IServiceOutput serviceOutput,
string winerrorXml)
{
this.serviceOutput = serviceOutput;
this.winerrorXml = winerrorXml;
winerrorXmlDocument = new XmlDocument();
winerrorXmlDocument.Load(winerrorXml);
}
public bool CanHandle(string commandName)
{
return CanHandle(commandName,
new string[] { "winerror" });
}
public void Handle(MessageContext context,
string commandName,
string parameters)
{
string winerrorText = parameters;
if (winerrorText.Equals(String.Empty))
{
serviceOutput.WriteLine(context,
"Please provide a valid System Error Code value.");
return;
}
NumberParser np = new NumberParser();
long winerror = np.Parse(winerrorText);
if (np.Error)
{
serviceOutput.WriteLine(context,
String.Format("{0} is not a valid System Error Code value.",
winerrorText));
return;
}
string description = GetWinerrorDescription(winerror);
if (description != null)
{
serviceOutput.WriteLine(context,
String.Format("{0} is {1}.",
winerrorText,
description));
}
else
{
serviceOutput.WriteLine(context,
String.Format("I don't know about System Error Code {0}.",
winerrorText));
}
}
public string Help()
{
return "!winerror <value>";
}
private string GetWinerrorDescription(long winerror)
{
XmlElement root = winerrorXmlDocument.DocumentElement;
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
winerror));
if (node != null)
{
XmlAttribute text = node.Attributes["text"];
if (text == null)
throw new Exception("Node has no text attribute.");
return text.Value;
}
else
return null;
}
}
}

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TechBot.Library.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<TechBot.Library.Settings>
<setting name="NtStatusXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\ntstatus.xml</value>
</setting>
<setting name="WinErrorXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\winerror.xml</value>
</setting>
<setting name="HResultXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\hresult.xml</value>
</setting>
<setting name="WMXml" serializeAs="String">
<value>C:\Ros\current\irc\TechBot\Resources\wm.xml</value>
</setting>
<setting name="SVNRoot" serializeAs="String">
<value>svn://svn.reactos.org/reactos/trunk</value>
</setting>
<setting name="CommandPrefix" serializeAs="String">
<value>!</value>
</setting>
</TechBot.Library.Settings>
</applicationSettings>
</configuration>

36
irc/TechBot/TechBot.cmbx Normal file
View File

@@ -0,0 +1,36 @@
<Combine fileversion="1.0" name="TechBot" description="">
<StartMode startupentry="TechBot" single="True">
<Execute entry="TechBot" type="None" />
<Execute entry="TechBot.Library" type="None" />
<Execute entry="CHMLibrary" type="None" />
<Execute entry="Compression" type="None" />
<Execute entry="TechBot.Console" type="None" />
<Execute entry="TechBot.IRCLibrary" type="None" />
</StartMode>
<Entries>
<Entry filename=".\TechBot\TechBot.prjx" />
<Entry filename=".\TechBot.Library\TechBot.Library.prjx" />
<Entry filename=".\CHMLibrary\CHMLibrary.prjx" />
<Entry filename=".\Compression\Compression.prjx" />
<Entry filename=".\TechBot.Console\TechBot.Console.prjx" />
<Entry filename=".\TechBot.IRCLibrary\TechBot.IRCLibrary.prjx" />
</Entries>
<Configurations active="Debug">
<Configuration name="Release">
<Entry name="TechBot" configurationname="Debug" build="False" />
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
<Entry name="CHMLibrary" configurationname="Debug" build="False" />
<Entry name="Compression" configurationname="Debug" build="False" />
<Entry name="TechBot.Console" configurationname="Debug" build="False" />
<Entry name="TechBot.IRCLibrary" configurationname="Debug" build="False" />
</Configuration>
<Configuration name="Debug">
<Entry name="TechBot" configurationname="Debug" build="False" />
<Entry name="TechBot.Library" configurationname="Debug" build="False" />
<Entry name="CHMLibrary" configurationname="Debug" build="False" />
<Entry name="Compression" configurationname="Debug" build="False" />
<Entry name="TechBot.Console" configurationname="Debug" build="False" />
<Entry name="TechBot.IRCLibrary" configurationname="Debug" build="False" />
</Configuration>
</Configurations>
</Combine>

View File

@@ -1,62 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot", "TechBot\TechBot.csproj", "{106F437D-424B-4758-A69C-862D08D26F3D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compression", "Compression\Compression.csproj", "{E32307F1-623A-4E62-826F-56CDD4B23A54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CHMLibrary", "CHMLibrary\CHMLibrary.csproj", "{72E5CCA1-6318-4D62-964D-CB23A5C743B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Console", "TechBot.Console\TechBot.Console.csproj", "{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.IRCLibrary", "TechBot.IRCLibrary\TechBot.IRCLibrary.csproj", "{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Library", "TechBot.Library\TechBot.Library.csproj", "{1114F34D-F388-4F38-AE27-C0EE1B10B777}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.Common", "TechBot.Commands.Common\TechBot.Commands.Common.csproj", "{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.MSDN", "TechBot.Commands.MSDN\TechBot.Commands.MSDN.csproj", "{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.Build.0 = Release|Any CPU
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.Build.0 = Release|Any CPU
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.Build.0 = Release|Any CPU
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.Build.0 = Release|Any CPU
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.Build.0 = Release|Any CPU
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.Build.0 = Release|Any CPU
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.Build.0 = Release|Any CPU
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,44 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TechBot.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="IRCServerHostName" value="irc.freenode.net" />
<add key="IRCServerHostPort" value="6667" />
<add key="IRCChannelNames" value="reactos,reactos-dev,reactos-testers" />
<add key="IRCBotName" value="MyBot" />
<add key="IRCBotPassword" value="MyPassword" />
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
<add key="MainChm" value="kmarch.chm" />
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
<add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
<add key="WmXml" value="C:\IRC\TechBot\wm.xml" />
<add key="SvnCommand" value="svn co svn://svn.reactos.org/reactos/trunk" />
<add key="BugUrl" value="http://www.reactos.org/bugzilla/show_bug.cgi?id={0}" />
<add key="WineBugUrl" value="http://bugs.winehq.org/show_bug.cgi?id={0}" />
<add key="SambaBugUrl" value="https://bugzilla.samba.org/show_bug.cgi?id={0}" />
</appSettings>
<userSettings>
<TechBot.Settings>
<setting name="IRCServerHostName" serializeAs="String">
<value>irc.eu.freenode.net</value>
</setting>
<setting name="IRCChannelNames" serializeAs="String">
<value>rbuildbottest</value>
</setting>
<setting name="IRCBotName" serializeAs="String">
<value>RBuildBot</value>
</setting>
<setting name="IRCBotPassword" serializeAs="String">
<value>qwerty</value>
</setting>
<setting name="IRCServerHostPort" serializeAs="String">
<value>6667</value>
</setting>
</TechBot.Settings>
</userSettings>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="IRCServerHostName" value="irc.eu.freenode.net" />
<add key="IRCServerHostPort" value="6667" />
<add key="IRCChannelNames" value="channel1;channel2" />
<add key="IRCBotName" value="MyBot" />
<add key="ChmPath" value="C:\IRC\TechBot\CHM" />
<add key="MainChm" value="kmarch.chm" />
<add key="NtstatusXml" value="C:\IRC\TechBot\ntstatus.xml" />
<add key="WinerrorXml" value="C:\IRC\TechBot\winerror.xml" />
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
<add key="SvnCommand" value="svn co svn://svn.reactos.com/trunk/reactos" />
</appSettings>
</configuration>

View File

@@ -1,28 +0,0 @@
using System;
using System.ComponentModel;
using System.ServiceProcess;
using System.Configuration.Install;
using System.Collections.Generic;
using System.Text;
namespace TechBot
{
[RunInstaller(true)]
public class ProjectInstaller : Installer
{
public ProjectInstaller()
{
ServiceProcessInstaller spi = null;
ServiceInstaller si = null;
spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount.LocalSystem;
si = new ServiceInstaller();
si.ServiceName = "TechBot";
si.StartType = ServiceStartMode.Automatic;
Installers.AddRange(new Installer[] { spi, si });
}
}
}

View File

@@ -1,43 +1,71 @@
using System;
using System.Configuration;
using System.Diagnostics;
using TechBot.Library;
namespace TechBot
{
public class ServiceThread
{
private EventLog m_EventLog;
public ServiceThread(EventLog eventLog)
{
m_EventLog = eventLog;
}
public void Run()
{
System.Console.WriteLine("TechBot irc service...");
IrcTechBotService ircService = new IrcTechBotService(
Settings.Default.IRCServerHostName,
Settings.Default.IRCServerHostPort,
Settings.Default.IRCChannelNames,
Settings.Default.IRCBotName,
Settings.Default.IRCBotPassword);
ircService.Run();
}
public void Start()
{
try
{
Run();
}
catch (Exception ex)
{
m_EventLog.WriteEntry(String.Format("Ex. {0}", ex));
}
}
}
}
using System;
using System.Configuration;
using System.Diagnostics;
using TechBot.Library;
namespace TechBot
{
public class ServiceThread
{
private string IRCServerHostName;
private int IRCServerHostPort;
private string IRCChannelNames;
private string IRCBotName;
private string ChmPath;
private string MainChm;
private string NtstatusXml;
private string HresultXml;
private string WinerrorXml;
private string SvnCommand;
private EventLog eventLog;
public ServiceThread(EventLog eventLog)
{
this.eventLog = eventLog;
}
private void SetupConfiguration()
{
IRCServerHostName = ConfigurationSettings.AppSettings["IRCServerHostName"];
IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);
IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];
IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];
ChmPath = ConfigurationSettings.AppSettings["ChmPath"];
MainChm = ConfigurationSettings.AppSettings["MainChm"];
NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];
HresultXml = ConfigurationSettings.AppSettings["HresultXml"];
WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"];
SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"];
}
public void Run()
{
SetupConfiguration();
System.Console.WriteLine("TechBot irc service...");
IrcService ircService = new IrcService(IRCServerHostName,
IRCServerHostPort,
IRCChannelNames,
IRCBotName,
ChmPath,
MainChm,
NtstatusXml,
WinerrorXml,
HresultXml,
SvnCommand);
ircService.Run();
}
public void Start()
{
try
{
Run();
}
catch (Exception ex)
{
eventLog.WriteEntry(String.Format("Ex. {0}", ex));
}
}
}
}

View File

@@ -1,86 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TechBot {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")]
public string IRCServerHostName {
get {
return ((string)(this["IRCServerHostName"]));
}
set {
this["IRCServerHostName"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest")]
public string IRCChannelNames {
get {
return ((string)(this["IRCChannelNames"]));
}
set {
this["IRCChannelNames"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("RBuildBot")]
public string IRCBotName {
get {
return ((string)(this["IRCBotName"]));
}
set {
this["IRCBotName"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("qwerty")]
public string IRCBotPassword {
get {
return ((string)(this["IRCBotPassword"]));
}
set {
this["IRCBotPassword"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("6667")]
public int IRCServerHostPort {
get {
return ((int)(this["IRCServerHostPort"]));
}
set {
this["IRCServerHostPort"] = value;
}
}
}
}

View File

@@ -1,21 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TechBot" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="IRCServerHostName" Type="System.String" Scope="User">
<Value Profile="(Default)">irc.eu.freenode.net</Value>
</Setting>
<Setting Name="IRCChannelNames" Type="System.String" Scope="User">
<Value Profile="(Default)">rbuildbottest</Value>
</Setting>
<Setting Name="IRCBotName" Type="System.String" Scope="User">
<Value Profile="(Default)">RBuildBot</Value>
</Setting>
<Setting Name="IRCBotPassword" Type="System.String" Scope="User">
<Value Profile="(Default)">qwerty</Value>
</Setting>
<Setting Name="IRCServerHostPort" Type="System.Int32" Scope="User">
<Value Profile="(Default)">6667</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{106F437D-424B-4758-A69C-862D08D26F3D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechBot</RootNamespace>
<AssemblyName>TechBot</AssemblyName>
<StartupObject>TechBot.TechBotService</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<None Include="App.config" />
<None Include="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ServiceThread.cs" />
<Compile Include="Settings.Designer.cs">
<DependentUpon>Settings.settings</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="TechBotService.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TechBot.IRCLibrary\TechBot.IRCLibrary.csproj">
<Project>{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}</Project>
<Name>TechBot.IRCLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\TechBot.Library\TechBot.Library.csproj">
<Project>{1114F34D-F388-4F38-AE27-C0EE1B10B777}</Project>
<Name>TechBot.Library</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

View File

@@ -9,7 +9,7 @@ using System.Configuration.Install;
namespace TechBot
{
public class TechBotService : ServiceBase
public class TechBotService : System.ServiceProcess.ServiceBase
{
private Thread thread;
private ServiceThread threadWorker;
@@ -80,3 +80,18 @@ namespace TechBot
}
}
}
[RunInstaller(true)]
public class ProjectInstaller : Installer
{
public ProjectInstaller()
{
ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount.LocalSystem;
ServiceInstaller si = new ServiceInstaller();
si.ServiceName = "TechBot";
si.StartType = ServiceStartMode.Automatic;
Installers.AddRange(new Installer[] {spi, si});
}
}

2
msvc6/.cvsignore Normal file
View File

@@ -0,0 +1,2 @@
*.ncb
*.opt

102
msvc6/README.txt Normal file
View File

@@ -0,0 +1,102 @@
ReactOS Microsoft Visual C/C++ 6.0 IDE files
This is the Microsoft Visual C/C++ 6.0 project workspace and project
files for a few of the ReactOS binaries. They are ONLY included as a
convenience, and is NOT to be considered supported, or even correct.
If you build a binary that misbehaves using these files, you _might_
be able to get in touch with someone to fix the problem
BUT DO NOT COUNT ON IT!
The only supported build system for ReactOS is the one documented at
www.reactos.com.
------------------------------------------------------------------
Please, before you start playing with this, read the whole of
this document.
Before you can use these project files, you _need_ to make a successful
build using the normal ReactOS build system. There are some vital files
that needs to be created, and currently only the normal build creates these.
Once that is done, you need to generate the kernel-mode service "table"
file by running nmake (from this point on you can use the "native"
MSVC tools) from the directory MSVC6\iface\native.
This will generate MSVC6\ntoskrnl\nt_zw_msvc.c, an MSVC compatible inline-
assembler version of the file otherwise known as reactos\ntoskrnl\nt\zw.c.
Next, go to def_converter and run nmake. This builds the tool to convert
the .def files for HAL and the kernel from the MinGW format to something
more suitable for the MSVC linker, and also generates these .def files
to their target location [1].
Now you should be set to fire up the IDE and load the project workspace.
When building HAL or the kernel for the first time using these
project files, just doing it the "normal" way _will not work_.
The linker will complain about missing library, and it will fail.
The reason for this is a circular dependency between these two binaries.
Currently you need to follow these procedures [2]:
- Select hal as your active project.
- Select Project/Settings.
- Select the Link tab.
- Select "General" from the Category drop-list.
- Temporary remove the explicit linker library
(e.g. "..\ntoskrnl\Debug\ntoskrnl.lib")
- Select "Customize" from the Category drop-list.
- Check the "Force file output" checkbox.
- Build hal.
- Uncheck "Force file output".
- Put back the removed import library.
- Now build the ntoskrnl. Do NOT try to build hal again until
you have sucessfully built the kernel, and the linker has
generated its import library!
- Now you can "Clean" hal, and build it as usual.
If everything worked as expected, you should now have both ntoskrnl.exe
and hal.dll freshly built.
LIMITATIONS/DEVIATIONS (from the MinGW build):
- Since there can only be one resource file/project, the kernel had
to choose between either its version resource, or its message table.
The messages won.
- Do NOT open the .rc files in the IDE's resource editor. Chances are
it will assume ownership over them and fill them up with at least
conditional compilation macros.
NOTES:
[1] This is needed due to differences in handling of decorated names
in .def files. While both MinGW GCC and MSVC generates decorated names
in the same way for at least plain cdecl and stdcall C functions, the
MSVC linker expects names in the .def file to be either
- an exact match of the decorated name, in case it exports the
decorated name from the linked binary, or
- just the name without any decoration, in case it exports just the
name of the symbol from the linked binary (to allow for e.g.
GetProcAddress using the undecorated name) - but keeps the decorated
names in the import library to handle and "redirect" linker requests
for those decorated symbols, and point them to the undercorated names
in the binary exporting them - so that a binary A, at link time,
importing symbols from binary B of the form "_name@0" will resolve
that symbol from the import library, but the linked binary A will
reference it as just "name".
The ROS .def files contains a mix, "half-decorated", where the leading
undescores are missing, but the trailing "@n" (for stdcall functions)
are present.
[2] Theoretically it could be possible to use a hal.lib generated by the
following procedure, removing the need for the manual steps above.
cd MSVC6\hal\Debug
lib \def:..\..\..\reactos\hal\hal\hal.def
but I have not tested it, and take no responsibility for its effectiveness.

41
msvc6/ReactOS.dsw Normal file
View File

@@ -0,0 +1,41 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "hal"=.\hal\hal.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "ntoskrnl"=.\ntoskrnl\ntoskrnl.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Some files were not shown because too many files have changed in this diff Show More