1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
#pike __REAL_VERSION__ 
 
//! IRC client and connection handling. 
//!  
//! Start with @ref{Client@} and @ref{Channel@}. 
//! 
//! @example 
//! Protocols.IRC.client irc; 
//! class channel_notif 
//! { 
//!     inherit Protocols.IRC.Channel; 
//!     void not_message(object person,string msg) 
//!     { 
//!         if (msg == "!hello") irc->send_message(name, "Hello, "+person->nick+"!"); 
//!     } 
//! } 
//! int main() 
//! { 
//!     irc = Protocols.IRC.Client("irc.freenode.net", ([ 
//!         "nick": "DemoBot12345", 
//!         "realname": "Demo IRC bot", 
//!         "channel_program": channel_notif, 
//!     ])); 
//!     irc->join_channel("#bot-test"); 
//!     return -1; 
//! } 
 
 
//! Abstract class for a person. 
class Person 
{ 
  //! User nickname, e.g. @expr{"Mirar"@}. 
  string nick; 
 
  //! User name, e.g. @expr{"mirar"@}. 
  string user; 
 
  //! User domain, e.g. @expr{"mistel.idonex.se"@}. 
  string ip; 
 
  //! Time of last action, represented as posix time. 
  int last_action; 
 
   multiset aka=(<>); 
   string realname="?"; 
   string server=0; 
 
   mapping misc=([]); 
   multiset channels=(<>); 
 
   void say(string message); 
   void notice(string message); 
   void me(string what); 
} 
 
//! Abstract class for an IRC channel. 
class Channel 
{ 
   //! The name of the channel. 
   string name; 
 
   //! Called whenever a message arrives on this channel. 
   void not_message(Person who,string message) { } 
 
   //! Called whenever someone joins this channel. 
   void not_join(Person who) { } 
 
   void not_part(Person who,string message,Person executor) { } 
   void not_mode(Person who,string mode) { } 
   void not_failed_to_join() { } 
   void not_invite(Person who) { } 
}