blob: cc2bdefca2473e30d1ef344a0179ceb44ed0542f [file] [log] [blame]
Zesstra83f011d2016-04-24 20:09:05 +02001#pragma strict_types, save_types, rtt_checks, pedantic
2#pragma no_clone, no_shadow, no_inherit
3
4inherit __DIR__"i_service";
5
6#include <intermud.h>
7#include <config.h>
8
9int maxtoday, maxever;
10
11public string service_name()
12{
13 return "who";
14}
15
16public void reset()
17{
18 string tmp1=read_file("/etc/maxusers.ever",0,1);
19 string tmp2=read_file("/etc/maxusers",0,1);
20 if (stringp(tmp1)&&sizeof(tmp1)) sscanf(tmp1,"%d %~s",maxever);
21 if (stringp(tmp2)&&sizeof(tmp2)) sscanf(tmp2,"%d %~s",maxtoday);
22}
23
24protected void create()
25{
26 ::create();
27 reset();
28}
29
30string adjust(string str,int wid) {
31 return sprintf("%*|s",wid,str);
32}
33
34// we received an intermud who request
35protected void recv_request(mapping data)
36{
37 string *lines="/obj/werliste"->QueryWhoListe(0, 1);
38 string wholiste=implode(lines,"\n");
39
40 lines=({
41 "*------------------------------------------------------------------------*",
42 "","","","",
43 "*------------------------------------------------------------------------*"
44 });
45 string header=MUDNAME", LDMud "+__VERSION__;
46 lines[1]="|"+adjust(header,sizeof(lines[0])-2)+"|";
47 header="Adresse: MG.Mud.DE (87.79.24.60) 23 (alternativ 4711)";
48 lines[2]="|"+adjust(header,sizeof(lines[0])-2)+"|";
49 header="Uptime: "+uptime();
50 lines[3]="|"+adjust(header,sizeof(lines[0])-2)+"|";
51 header=_MUDLIB_NAME_"-Mudlib "_MUDLIB_VERSION_;
52 lines[4]="|"+adjust(header,sizeof(lines[0])-2)+"|";
53 header=implode(lines,"\n");
54
55 wholiste=header+"\n"+wholiste+
56 sprintf("\n*** Anwesende im "MUDNAME": Max. heute %d, Rekord %d\n",
57 maxtoday,maxever);
58
59 INETD->send(data[NAME],
60 ([REQUEST: REPLY, ID: data[ID],
61 RECIPIENT: data[SENDER],
62 DATA: wholiste
63 ]), 0);
64}
65
66//TODO: request() ?
67//public int request(string mudname, string|int data)
68