/[cvs]/eggdrop1.9/src/core_party.c
ViewVC logotype

Contents of /eggdrop1.9/src/core_party.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Sun Jun 15 05:43:24 2003 UTC (16 years, 4 months ago) by stdarg
Branch: MAIN
Changes since 1.6: +70 -0 lines
File MIME type: text/x-chdr
*** empty log message ***

1 #include <eggdrop/eggdrop.h>
2 #include "core_config.h"
3
4 static int party_join(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
5 {
6 if (!text || !strlen(text)) {
7 partymember_write(p, "Syntax: join <channel>", -1);
8 return(0);
9 }
10 partychan_join_name(text, p);
11 return(0);
12 }
13
14 static int party_part(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
15 {
16 partychan_t *chan;
17
18 if (!text || !strlen(text)) chan = partychan_get_default(p);
19 else chan = partychan_lookup_name(text);
20 partychan_part(chan, p, "parting");
21 return(0);
22 }
23
24 static int party_quit(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
25 {
26 if (!text) text = "Quit";
27 partymember_write(p, "goodbye!", -1);
28 partymember_delete(p, text);
29 return(0);
30 }
31
32 static int party_msg(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
33 {
34 return(0);
35 }
36
37 static int party_set(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
38 {
39 return(0);
40 }
41
42 static int party_save(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
43 {
44 user_save(core_config.userfile);
45 core_config_save();
46 return(1);
47 }
48
49 static int party_newpass(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
50 {
51 if (!text || strlen(text) < 6) {
52 partymember_write(p, "Please use at least 6 characters.", -1);
53 return(0);
54 }
55 user_set_pass(p->user, text);
56 partymember_printf(p, "Changed password to '%s'", text);
57 return(0);
58 }
59
60 static int intsorter(const void *left, const void *right)
61 {
62 return(*(int *)left - *(int *)right);
63 }
64
65 static int party_who(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
66 {
67 partymember_t *who;
68 int *pids, len, i;
69
70 partymember_printf(p, "Partyline members");
71 partymember_who(&pids, &len);
72 qsort(pids, len, sizeof(int), intsorter);
73 for (i = 0; i < len; i++) {
74 who = partymember_lookup_pid(pids[i]);
75 partymember_printf(p, " [%.5d] %s (%s@%s)", who->pid, who->nick, who->ident, who->host);
76 }
77 free(pids);
78 return(0);
79 }
80
81 static int party_die(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
82 {
83 exit(0);
84 }
85
86 static int party_plus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
87 {
88 user_t *newuser;
89
90 if (!text || !*text) {
91 partymember_printf(p, "Syntax: +user <handle>");
92 return(0);
93 }
94 if (user_lookup_by_handle(text)) {
95 partymember_printf(p, "User '%s' already exists!");
96 return(0);
97 }
98 newuser = user_new(text);
99 if (newuser) partymember_printf(p, "User '%s' created", text);
100 else partymember_printf(p, "Could not create user '%s'", text);
101 return(0);
102 }
103
104 static int party_minus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
105 {
106 user_t *who;
107
108 if (!text || !*text) {
109 partymember_printf(p, "Syntax: -user <handle>");
110 return(0);
111 }
112 who = user_lookup_by_handle(text);
113 if (!who) partymember_printf(p, "User '%s' not found");
114 else {
115 partymember_printf(p, "Deleting user '%s'", who->handle);
116 user_delete(who);
117 }
118 return(0);
119 }
120
121 static int party_plus_host(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
122 {
123 return(0);
124 }
125
126 static bind_list_t core_party_binds[] = {
127 {NULL, "join", party_join},
128 {NULL, "msg", party_msg},
129 {NULL, "newpass", party_newpass},
130 {NULL, "part", party_part},
131 {NULL, "quit", party_quit},
132 {NULL, "who", party_who},
133 {"n", "set", party_set},
134 {"n", "save", party_save},
135 {"n", "die", party_die},
136 {"n", "+user", party_plus_user},
137 {"n", "-user", party_minus_user},
138 {0}
139 };
140
141 void core_party_init()
142 {
143 bind_add_list("party", core_party_binds);
144 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23