out_tell.c
snippets · 2.4 KB · 2010-03-30
out_tell.c: intermud tell sender for LPMud.
Download « Back to the snippets list
#include <daemons.h>
#include "socket.h"
#include "/adm/net/inet.h"
object pl;
string who, message;
string mudd;
int count;
void dest_me();
void create() {
seteuid(getuid());
} /* create() */
/* Whats all this then? */
int do_tell(string str) {
string name, host, mess;
object ob;
if (sscanf(str, "%s@%s %s", name, host, mess) == 3) {
lower_case(name);
if (name == "")
name = "EVERYONE";
ob = clone_object(file_name(this_object()));
ob->tell_away(name, host, mess, this_player());
return 1;
}
return 0;
} /* do_finger() */
void tell_away(string name, string host, string mess, object me) {
who = name;
pl = me;
mudd = host;
message = mess;
INETD->open_to_service("tell", INETD_TYPE, host);
call_out("dest_me", 5*60*60);
} /* finger_away() */
void read_callback(int fd, string mess) {
string str, person, mud, who, message;
if (sscanf(mess, "%s@%s tells %s: %s\n", person, mud, who, message) != 4) {
sscanf(message, "%s\n", message);
previous_object()->write_fd(fd, "Tell_Server@"+"tabor"+" tells "+
"whoever-the-heck-this-is: You have "+
"an incorrect message format.\n");
} else if (!find_player(who)) {
previous_object() -> write_fd(fd, "Tell_Server@tabor tells " +
person+": Either "+who+" isn't logged on "+
"or you are a right womble.\n");
} else {
if (person == "TS") person = "Tell_Server";
tell_object(find_player(who),
wrap(FIGURE_D->figure_width( find_player(who) ),
capitalize(person) +
"@" + all_caps(mud) +
" tells you, '", message, "'"));
}
pl->tell_callback(2, mess);
} /* read_callback() */
void connected(int fd) {
if (pl->getenv("space")) tell_object(pl, "\n");
if ((int) pl->query_player_data("echospeak"))
tell_object(pl, wrap(FIGURE_D->figure_width(pl),
"You tell " + capitalize(who) + "@" + all_caps(mudd) + ", '", message, "'"));
else tell_object(pl, "Tell Sent.\n");
previous_object()->write_fd(fd, pl->query_name()+"@"+"tabor"+
" tells "+who+": "+message+"\n");
} /* write_callback() */
void close_callback() {
pl->tell_callback(0);
dest_me();
} /* close_callback() */
void failed(string reason) {
pl->tell_callback(1, reason);
tell_object(pl, "We failed for "+reason+" reason.\n");
dest_me();
} /* failed() */
void dest_me() {
destruct(this_object());
} /* dest_me() */