ArchBlackmann irc bot - works in ReactOS - happy hacking
[reactos.git] / rosapps / games / ArchBlackmann / ArchBlackmann.cpp
1 // irc_test.cpp
2
3 #ifdef _MSC_VER
4 #pragma warning ( disable : 4786 )
5 #endif//_MSC_VER
6
7 #include <conio.h>
8 #include <stdio.h>
9
10 #include "IRCClient.h"
11
12 using std::string;
13 using std::vector;
14
15 // do custom stuff with the IRCClient from your subclass via the provided callbacks...
16 class MyIRCClient : public IRCClient
17 {
18 public:
19 // see IRCClient.h for documentation on these callbacks...
20 bool OnConnected()
21 {
22 return true;
23 }
24 bool OnJoin ( const string& user, const string& channel )
25 {
26 return true;
27 }
28 bool OnEndChannelUsers ( const string& channel )
29 {
30 return true;
31 }
32 bool OnPrivMsg ( const string& from, const string& text )
33 {
34 printf ( "<%s> %s\n", from.c_str(), text.c_str() );
35 return true;
36 }
37 bool OnChannelMsg ( const string& channel, const string& from, const string& text )
38 {
39 printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() );
40 if ( !stricmp ( from.c_str(), "royce3" ) )
41 PrivMsg ( channel, text );
42 return true;
43 }
44 bool OnChannelMode ( const string& channel, const string& mode )
45 {
46 //printf ( "OnChannelMode(%s,%s)\n", channel.c_str(), mode.c_str() );
47 return true;
48 }
49 bool OnUserModeInChannel ( const string& src, const string& channel, const string& user, const string& mode )
50 {
51 //printf ( "OnUserModeInChannel(%s,%s%s,%s)\n", src.c_str(), channel.c_str(), user.c_str(), mode.c_str() );
52 return true;
53 }
54 bool OnMode ( const string& user, const string& mode )
55 {
56 //printf ( "OnMode(%s,%s)\n", user.c_str(), mode.c_str() );
57 return true;
58 }
59 bool OnChannelUsers ( const string& channel, const vector<string>& users )
60 {
61 printf ( "[%s has %i users]: ", channel.c_str(), users.size() );
62 for ( int i = 0; i < users.size(); i++ )
63 {
64 if ( i )
65 printf ( ", " );
66 printf ( "%s", users[i].c_str() );
67 }
68 printf ( "\n" );
69 return true;
70 }
71 };
72
73 int main ( int argc, char** argv )
74 {
75 printf ( "initializing IRCClient debugging\n" );
76 IRCClient::SetDebug ( true );
77 printf ( "calling suStartup()\n" );
78 suStartup();
79 printf ( "creating IRCClient object\n" );
80 MyIRCClient irc;
81 printf ( "connecting to freenode\n" );
82 if ( !irc.Connect ( "140.211.166.3" ) ) // irc.freenode.net
83 {
84 printf ( "couldn't connect to server\n" );
85 return -1;
86 }
87 printf ( "sending user command\n" );
88 if ( !irc.User ( "Royce3", "", "irc.freenode.net", "Royce Mitchell III" ) )
89 {
90 printf ( "USER command failed\n" );
91 return -1;
92 }
93 printf ( "sending nick\n" );
94 if ( !irc.Nick ( "Royce3" ) )
95 {
96 printf ( "NICK command failed\n" );
97 return -1;
98 }
99 printf ( "setting mode\n" );
100 if ( !irc.Mode ( "+i" ) )
101 {
102 printf ( "MODE command failed\n" );
103 return -1;
104 }
105 printf ( "joining #ReactOS\n" );
106 if ( !irc.Join ( "#ReactOS" ) )
107 {
108 printf ( "JOIN command failed\n" );
109 return -1;
110 }
111 printf ( "entering irc client processor\n" );
112 irc.Run ( true ); // do the processing in this thread...
113 string cmd;
114 for ( ;; )
115 {
116 char c = getch();
117 if ( c == '\n' || c == '\r' )
118 {
119
120 }
121 }
122 return 0;
123 }