Guest User

Untitled

a guest
Jan 4th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.34 KB | None | 0 0
  1. int main(int argc, char *argv[]) {
  2. //Parse Arguments
  3. char i;
  4. int curse = 1;
  5. while ((i = getopt(argc,argv,"c")) != -1) {
  6. switch (i) {
  7. case 'c':
  8. curse = 0;
  9. break;
  10. }
  11. }
  12.  
  13. //Login Info
  14. string uname, pword, url, chatip, cookie, aid, input, tag;
  15.  
  16. if (curse == 0) {
  17. cout<<"Username: ";
  18. cin>>uname;
  19. cout<<"Password: ";
  20. cin>>pword;
  21.  
  22. //MD5 Hash
  23. pword = MD5String((char*)pword.c_str());
  24.  
  25. //Get Serialized Information
  26. url = login(uname,pword);
  27.  
  28. //Deserialize
  29. deserialize ds;
  30. vector<string> info = ds.process((char*)url.c_str());
  31.  
  32. for(unsigned int i = 0; i < info.size(); i++) {
  33. if (strstr(info[i].c_str(),"Invalid")) {
  34. cout<<"Invalid Username or Password.\n";
  35. exit(1);
  36. }
  37. else if (!strcmp(info[i].c_str(),"account_id")) {
  38. aid = info[i+1];
  39. }
  40. else if (!strcmp(info[i].c_str(),"chat_url")) {
  41. chatip = info[i+1];
  42. }
  43. else if (!strcmp(info[i].c_str(),"cookie")) {
  44. cookie = info[i+1];
  45. }
  46. else if (!strcmp(info[i].c_str(),"tag")) {
  47. tag = info[i+1];
  48. }
  49. else if (!strcmp(info[i].c_str(),"buddy_id")) {
  50. buddies buddy;
  51. buddy.id = (int*)malloc(sizeof(int));
  52. *buddy.id = atoi(info[i+1].c_str());
  53. i += 3;
  54. buddy.name = (char*)info[i].c_str();
  55. i += 4;
  56. buddy.tag = (char*)info[i].c_str();
  57. buddylist.push_back(buddy);
  58. }
  59. }
  60.  
  61. uname = "["+tag+"]"+uname;
  62.  
  63. //Start up the Curses screen and greet connection
  64. cursescr scr;
  65. scr.uname = uname;
  66. scr.mode = 0;
  67.  
  68. tcpwatch tcp;
  69. tcp.scrhandle = &scr;
  70.  
  71. //Start connection
  72. tcp.setaddress((char*)chatip.c_str());
  73. if (tcp.greet((char*)cookie.c_str(),(char*)aid.c_str()) != 0) {
  74. scr.paint_msg("Could not connect to the Heroes of Newerth Chat Server.");
  75. exit(1);
  76. }
  77. //Enter Main Loop
  78. while (true) {
  79. input = scr.readinput();
  80. if (input == "/quit") {
  81. break;
  82. }
  83. else if (input.substr(0,6) == "/join ") { //Join Channel
  84. tcp.newch((char*)input.substr(5).c_str(),(input.length()-6));
  85. }
  86. else if (input.substr(0,6) == "/leave") { //Leave Channel
  87. tcp.leavech();
  88. }
  89. else if (input.substr(0,7) == "/whois ") { //Whois Request
  90. tcp.whois((char*)input.c_str(),input.length());
  91. }
  92. else if (input.substr(0,3) == "/w ") { //Whisper
  93. tcp.whisper((char*)input.c_str(),input.length());
  94. }
  95. else if (input.length() != 0 && input[0] != '/') { //Normal Text Send
  96. tcp.sendtext((char*)input.c_str(), input.length());
  97. }
  98. tcp.rwrap();
  99. }
  100. }
  101. else {
  102. string dir = argv[0];
  103. size_t place = dir.find_last_of("/\\");
  104. chdir(dir.substr(0,place).c_str());
  105. gtkscr scr;
  106. tcpwatch tcp;
  107. int retval = 0;
  108. scr.id = 0;
  109. logged_on = FALSE;
  110. char null[] = {0x00};
  111.  
  112. if (read_pref("r") == "yes" && read_pref("u") != "") {
  113. scr.uname = read_pref("u");
  114. scr.pword = read_pref("p");
  115. logged_on = TRUE;
  116. }
  117.  
  118. while (retval != -1) {
  119. do {
  120. switch (retval) {
  121. case 1: //Stats Window
  122. scr.statwindow(NULL);
  123. break;
  124. case 2: //Connect
  125. if (logged_on == TRUE) {
  126. tcp.dc();
  127. }
  128. logged_on = scr.login();
  129. break;
  130. case 3: //Disconnect
  131. if (logged_on == TRUE) {
  132. tcp.dc();
  133. logged_on = FALSE;
  134. }
  135. break;
  136. case 4: //Setup Window
  137. scr.setupwindow();
  138. break;
  139. default:
  140. break;
  141. }
  142. if (logged_on == FALSE) {
  143. scr.mainloop(FALSE);
  144. retval = statushandler();
  145. }
  146. } while (logged_on == FALSE);
  147. uname = scr.uname;
  148. pword = scr.pword;
  149.  
  150. if (pword.length() != 32) {
  151. //MD5 Hash
  152. pword = MD5String((char*)pword.c_str());
  153.  
  154. if (read_pref("r") == "yes") {
  155. write_pref("u",uname);
  156. write_pref("p",pword);
  157. }
  158. }
  159.  
  160. //Get Serialized Information
  161. url = login(uname,pword);
  162.  
  163. //Deserialize
  164. deserialize ds;
  165. vector<string> info = ds.process((char*)url.c_str());
  166. for(unsigned int i = 0; i < info.size(); i++) {
  167. if (strstr(info[i].c_str(),"Invalid")) {
  168. scr.paint_msg("Invalid Username or Password.");
  169. scr.mainloop(FALSE);
  170. retval = statushandler();
  171. logged_on = FALSE;
  172. break;
  173. }
  174. else if (!strcmp(info[i].c_str(),"account_id")) {
  175. int id = atoi(info[i+1].c_str());
  176. aid = info[i+1];
  177. if (scr.id == 0) {scr.id = id;}
  178. }
  179. else if (!strcmp(info[i].c_str(),"chat_url")) {
  180. chatip = info[i+1];
  181. }
  182. else if (!strcmp(info[i].c_str(),"cookie")) {
  183. cookie = info[i+1];
  184. }
  185. else if (!strcmp(info[i].c_str(),"tag")) {
  186. tag = info[i+1];
  187. }
  188. else if (!strcmp(info[i].c_str(),"buddy_id")) {
  189. buddies buddy;
  190. buddy.id = (int*)malloc(sizeof(int));
  191. *buddy.id = atoi(info[i+1].c_str());
  192. while (strcmp(info[i].c_str(),"nickname")) {i++;}
  193. buddy.name = (char*)info[i+1].c_str();
  194. while (strcmp(info[i].c_str(),"clan_tag")) {i++;}
  195. if (info[i+1] != ":N:") { //If user is in a clan (has a clan tag)
  196. buddy.tag = (char*)info[i+1].c_str();
  197. }
  198. else {buddy.tag = (char*)"";}
  199. char null[] = {0x00};
  200. buddy.status = (char*)malloc(1);
  201. memcpy(buddy.status,null,1);
  202. buddylist.push_back(buddy);
  203. }
  204. else if (!strcmp(info[i].c_str(),"ignored_list")) {
  205. int n = 0; i++;
  206. for (i; ;i++) {
  207. if (!strcmp(info[i].c_str(),":A:")) {
  208. n++;
  209. }
  210. else if (!strcmp(info[i].c_str(),":N:")) {
  211. n--;
  212. }
  213. else if (!strcmp(info[i].c_str(),"ignored_id")) {
  214. ignored ignoreuser;
  215. ignoreuser.id = (int*)malloc(sizeof(int));
  216. *ignoreuser.id = atoi(info[i+1].c_str());
  217. if (!strcmp(info[i+2].c_str(),"reason")) {
  218. ignoreuser.reason = (char*)info[i+3].c_str();
  219. } else { ignoreuser.reason = (char*)""; }
  220. while (strcmp(info[i].c_str(),"nickname")) {i++;}
  221. ignoreuser.name = (char*)info[i+1].c_str();
  222. ignorelist.push_back(ignoreuser);
  223. }
  224. if (n == 0 || !strcmp(info[i].c_str(),"error")) {
  225. break;
  226. }
  227. }
  228. }
  229. else if (!strcmp(info[i].c_str(),"banned_list")) {
  230. int n = 0; i++;
  231. for (i; ; i++) {
  232. if (!strcmp(info[i].c_str(),":A:")) {
  233. n++;
  234. }
  235. else if (!strcmp(info[i].c_str(),":N:")) {
  236. n--;
  237. }
  238. else if (!strcmp(info[i].c_str(),"banned_id")) {
  239. banned banuser;
  240. banuser.id = (int*)malloc(sizeof(int));
  241. *banuser.id = atoi(info[i+1].c_str());
  242. if (!strcmp(info[i+2].c_str(),"reason")) {
  243. banuser.reason = (char*)info[i+3].c_str();
  244. } else { banuser.reason = (char*)""; }
  245. while (strcmp(info[i].c_str(),"nickname")) {i++;}
  246. banuser.name = (char*)info[i+1].c_str();
  247. banlist.push_back(banuser);
  248. }
  249. if (n == 0 || !strcmp(info[i].c_str(),"error")) {
  250. break;
  251. }
  252. }
  253. }
  254. else if (!strcmp(info[i].c_str(),"clan_member_info")) {
  255. if (!strcmp(info[i+2].c_str(),"error")) {scr.clanname = ""; scr.clantag = ""; break;} //Catch users with no clan
  256. while (strcmp(info[i].c_str(),"name")) {i++;}
  257. scr.clanname = (char*)info[i+1].c_str();
  258. scr.clantag = (char*)info[i+3].c_str();
  259. }
  260. else if (!strcmp(info[i].c_str(),"clan_roster")) {
  261. while (i < info.size()) {
  262. if (!strcmp(info[i].c_str(),"account_id")) {
  263. clan member;
  264. member.id = (int*)malloc(sizeof(int));
  265. *member.id = atoi(info[i+1].c_str());
  266. while (strcmp(info[i].c_str(),"nickname")) {i++;}
  267. member.name = (char*)info[i+1].c_str();
  268. member.status = (char*)malloc(1);
  269. char null[] = {0x00};
  270. memcpy(member.status,null,1);
  271. clanlist.push_back(member);
  272. }
  273. i++;
  274. }
  275. }
  276. }
  277. if (logged_on == TRUE) {
  278. if (tag != "") {
  279. uname = "["+tag+"]"+uname;
  280. }
  281. tag = "";
  282.  
  283. scr.uname = uname;
  284. scr.mode = 1;
  285. scr.log_on();
  286.  
  287. tcp.scrhandle = &scr;
  288. tcp.setaddress((char*)chatip.c_str());
  289. if (tcp.greet((char*)cookie.c_str(),(char*)aid.c_str()) != 0) {
  290. scr.paint_msg("Could not connect to the Heroes of Newerth Chat Server.");
  291. scr.mainloop(FALSE);
  292. retval = statushandler();
  293. logged_on = FALSE;
  294. }
  295. else {scr.clanupdate();}
  296.  
  297. if (read_pref("c") != "") {
  298. tcp.leavech();
  299. string chans = read_pref("c");
  300. string chan;
  301. for (int i=0; i < chans.length()+1; i++) {
  302. if (chans[i] == ',' || chans[i] == '\0') {
  303. tcp.newch((char*)chan.c_str(),chan.length());
  304. chan.clear();
  305. }
  306. else {chan += chans[i];}
  307. }
  308. }
  309.  
  310. while (logged_on == TRUE) {
  311. //Handle Text Input
  312. input = scr.mainloop(TRUE);
  313. if (input == "/quit") {
  314. scr.destroy();
  315. break;
  316. }
  317. else if (input.substr(0,5) == "/help") {
  318. scr.print_help();
  319. }
  320. else if (input.substr(0,6) == "/join ") {
  321. tcp.newch((char*)input.substr(6).c_str(),(input.length()-6));
  322. }
  323. else if (input.substr(0,6) == "/leave") {
  324. tcp.leavech();
  325. }
  326. else if (input.substr(0,5) == "/msg " && input.length() > 5) { //Private Message
  327. scr.privchat((char*)input.substr(5,(input.length()-5)).c_str(),FALSE);
  328. tcp.storage[tcp.numchan].name = (char*)input.substr(5,(input.length()-5)).c_str();
  329. tcp.storage[tcp.numchan].id = (char*)"privchat";
  330. tcp.numchan++;
  331. }
  332. else if (input.substr(0,7) == "/emote ") {
  333. tcp.emote((char*)input.substr(7,input.length()-7).c_str());
  334. }
  335. else if (input.substr(0,5) == "/stat") { //Stats
  336. if (input[5] == ' ' && input.length() > 8) {
  337. scr.statwindow((char*)input.substr(6,input.length()-6).c_str());
  338. }
  339. else { scr.statwindow(NULL); }
  340. }
  341. else if (input.substr(0,7) == "/whois ") { //Whois Request
  342. tcp.whois((char*)input.c_str(),input.length());
  343. }
  344. else if (input.substr(0,3) == "/w ") {
  345. tcp.whisper((char*)input.c_str(),input.length());
  346. }
  347. else if (input.substr(0,1) == "\\") { //Priv Message Send
  348. tcp.privmsg((char*)input.c_str(),input.length());
  349. }
  350. else if (input.substr(0,9) == "/banlist " && input.length() > 7) {
  351. ds.flush();
  352. string out;
  353. if (input.substr(9,4) == "add ") {
  354. char* tid = nick2id((char*)input.substr(13,input.length()-13).c_str());
  355. if (tid != "-1") {
  356. ban(scr.id,tid,(char*)"",(char*)cookie.c_str(),TRUE);
  357. out = "Username " + input.substr(13,input.length()-13) + " successfully banned.";
  358. }
  359. else {out = "Username " + input.substr(13,input.length()-13) + " not found.";}
  360. scr.paint_msg(out);
  361. }
  362. if (input.substr(9,7) == "remove ") {
  363. char* tid = nick2id((char*)input.substr(16,input.length()-16).c_str());
  364. if (tid != "-1") {
  365. ban(scr.id,tid,(char*)"",(char*)cookie.c_str(),FALSE);
  366. out = "Username " + input.substr(16,input.length()-16) + " removed from banlist.";
  367. }
  368. else {out = "Username " + input.substr(16,input.length()-16) + " not found.";}
  369. scr.paint_msg(out);
  370. }
  371. if (input.substr(9,4) == "list") {
  372. string out;
  373. for (unsigned int i = 0; i < banlist.size(); i++) {
  374. out = "^r" + (string)banlist[i].name + " ^m" + (string)banlist[i].reason;
  375. scr.paint_msg(out);
  376. }
  377. if (banlist.size() == 0) {
  378. scr.paint_msg("^bNo users in your banlist!");
  379. }
  380. }
  381. if (input.substr(9,4) == "help") {
  382. string helpinfo;
  383. helpinfo = "Banlist Commands:\n";
  384. helpinfo += "\t/banlist add [user]\t\tAdd 'user' to your banlist.\n";
  385. helpinfo += "\t/banlist remove [user]\t\tRemove 'user' from your banlist.\n";
  386. helpinfo += "\t/banlist list\t\t\tList the users in your banlist.\n";
  387. helpinfo += "\t/banlist help\t\t\tShow this help information.";
  388. scr.paint_msg(helpinfo);
  389. }
  390. }
  391. else if (input.substr(0,8) == "/ignore " && input.length() > 10) {
  392. ds.flush();
  393. if (input.substr(8,4) == "add ") {
  394. string out;
  395. char* tid = nick2id((char*)input.substr(12,input.length()-12).c_str());
  396. if (tid != "-1") {
  397. ignore(scr.id,tid,(char*)"",(char*)cookie.c_str(),TRUE);
  398. out = "Username " + input.substr(12,input.length()-12) + " set to ignore.";
  399. }
  400. else {out = "Username " + input.substr(12,input.length()-12) + " not found.";}
  401. scr.paint_msg(out);
  402. }
  403. if (input.substr(8,7) == "remove ") {
  404. string out;
  405. char* tid = nick2id((char*)input.substr(15,input.length()-15).c_str());
  406. if (tid != "-1") {
  407. ignore(scr.id,tid,(char*)"",(char*)cookie.c_str(),FALSE);
  408. out = "Username " + input.substr(15,input.length()-15) + " no longer ignored.";
  409. }
  410. else {out = "Username " + input.substr(15,input.length()-15) + " not found.";}
  411. scr.paint_msg(out);
  412. }
  413. if (input.substr(8,4) == "list") {
  414. string out;
  415. for (unsigned int i = 0; i < ignorelist.size(); i++) {
  416. out = "^r" + (string)ignorelist[i].name + " ^m" + (string)ignorelist[i].reason;
  417. scr.paint_msg(out);
  418. }
  419. if (ignorelist.size() == 0) {
  420. scr.paint_msg("^bNo users in your ignore list!");
  421. }
  422. }
  423. if (input.substr(8,4) == "help") {
  424. string helpinfo;
  425. helpinfo = "Ignore Commands:\n";
  426. helpinfo += "\t/ignore add [user]\t\tAdd 'user' to your ignore list.\n";
  427. helpinfo += "\t/ignore remove [user]\t\tRemove 'user' from your ignore list.\n";
  428. helpinfo += "\t/ignore list\t\t\t\tList the users in your ignore list.\n";
  429. helpinfo += "\t/ignore help\t\t\tShow this help information.";
  430. scr.paint_msg(helpinfo);
  431. }
  432. }
  433. else if ((input.substr(0,7) == "/buddy " && input.length() > 7) || (input.substr(0,3) == "/b " && input.length() > 3)) {
  434. if (input.substr(0,3) == "/b ") {
  435. input = "/buddy " + input.substr(3,input.length()-3);
  436. }
  437. ds.flush();
  438. if (input.substr(7,4) == "add ") {
  439. string out;
  440. char* nick = (char*)malloc(input.length()-11);
  441. memcpy(nick,&input.substr(11,input.length()-11)[0],input.length()-11);
  442. char* tid = nick2id(nick);
  443. if (tid != "-1") {
  444. buddy(scr.id,tid,(char*)cookie.c_str(),TRUE,nick);
  445. out = "Username " + input.substr(11,input.length()-11) + " added to buddylist.";
  446. scr.buddyupdate();
  447. }
  448. else {out = "Username " + input.substr(11,input.length()-11) + " not found.";}
  449. scr.paint_msg(out);
  450. }
  451. if (input.substr(7,7) == "delete ") {
  452. string out;
  453. char* tid = nick2id((char*)input.substr(14,input.length()-14).c_str());
  454. if (tid != "-1") {
  455. buddy(scr.id,tid,(char*)cookie.c_str(),FALSE);
  456. out = "Username " + input.substr(14,input.length()-14) + " deleted from buddylist.";
  457. scr.buddyupdate();
  458. }
  459. else {out = "Username " + input.substr(14,input.length()-14) + " not found.";}
  460. scr.paint_msg(out);
  461. }
  462. if (input.substr(7,4) == "list") {
  463. scr.buddy_list();
  464. }
  465. if (input.substr(7,8) == "message ") {
  466. tcp.buddy_message((char*)input.substr(15,input.length()-15).c_str());
  467. }
  468. if (input.substr(7,4) == "help") {
  469. string helpinfo;
  470. helpinfo = "Buddy Commands:\n";
  471. helpinfo += "\t/buddy list\t\t\t\tList buddies and their status.\n";
  472. helpinfo += "\t/buddy help\t\t\tShow this help information.\n";
  473. helpinfo += "\t/buddy message [msg]\tSend 'msg' to your buddies.\n";
  474. helpinfo += "\t/buddy add [user]\t\tAdd 'user' to your buddylist.\n";
  475. helpinfo += "\t/buddy delete [buddy]\tRemove 'buddy' from your buddylist.";
  476. scr.paint_msg(helpinfo);
  477. }
  478. scr.buddyupdate();
  479. }
  480. else if (input.substr(0,6) == "/clan ") {
  481. if (input.substr(6,7) == "invite ") {
  482. char* nick = (char*)malloc(input.length()-12);
  483. memcpy(nick,&input.substr(13,input.length()-13)[0],input.length()-13);
  484. memcpy(nick+(input.length()-13),null,1);
  485. tcp.clan_invite(nick);
  486. string out = "Invite sent to " + (string)nick + ".";
  487. scr.paint_msg(out);
  488. }
  489. else if (input.substr(6,7) == "delete ") {
  490. char* nick = (char*)malloc(input.length()-12);
  491. memcpy(nick,&input.substr(13,input.length()-13)[0],input.length()-13);
  492. memcpy(nick+(input.length()-13),null,1);
  493. tcp.clan_remove(nick);
  494. string out = (string)nick + " successfully removed from clan.";
  495. scr.paint_msg(out);
  496. }
  497. else if (input.substr(6,5) == "leave") {
  498. char* nick = (char*)uname.substr(scr.clantag.length()+2,uname.length()-(scr.clantag.length()+2)).c_str();
  499. tcp.clan_remove(nick);
  500. scr.paint_msg("You have left the clan.");
  501. }
  502. else if (input.substr(6,8) == "message ") {
  503. char* msg = (char*)malloc(input.length()-13);
  504. memcpy(msg,&input.substr(14,input.length()-14)[0],input.length()-14);
  505. memcpy(msg+(input.length()-14),null,1);
  506. tcp.clan_message(msg);
  507. }
  508. else if (input.substr(6,8) == "promote ") {
  509. char* nick = (char*)malloc(input.length()-13);
  510. memcpy(nick,&input.substr(14,input.length()-14)[0],input.length()-14);
  511. memcpy(nick+(input.length()-14),null,1);
  512. tcp.clan_mote(nick,TRUE);
  513. }
  514. else if (input.substr(6,7) == "demote ") {
  515. char* nick = (char*)malloc(input.length()-12);
  516. memcpy(nick,&input.substr(13,input.length()-13)[0],input.length()-13);
  517. memcpy(nick+(input.length()-13),null,1);
  518. tcp.clan_mote(nick,FALSE);
  519. }
  520. else if (input.substr(6,4) == "list") {
  521. scr.clan_list();
  522. }
  523. else if (input.substr(6,4) == "help") {
  524. string helpinfo;
  525. helpinfo = "Clan Commands:\n";
  526. helpinfo += "\t/clan list\t\t\t\tList clan members and status.\n";
  527. helpinfo += "\t/clan help\t\t\t\tShow this help information.\n";
  528. helpinfo += "\t/clan message [msg]\t\tSend 'msg' to your clan.\n";
  529. helpinfo += "\t/clan promote [member]\tPromote 'member' in the clan.\n";
  530. helpinfo += "\t/clan demote [member]\tDemote 'member' in the clan.\n";
  531. helpinfo += "\t/clan delete [member]\tRemove 'member' from the clan.\n";
  532. helpinfo += "\t/clan invite [user]\t\tInvite 'user' to the clan.\n";
  533. helpinfo += "\t/clan leave\t\t\tLeave the clan.";
  534. scr.paint_msg(helpinfo);
  535. }
  536. }
  537. else if (input.substr(0,7) == "/topic ") {
  538. tcp.topic((char*)input.substr(7,input.length()-7).c_str());
  539. }
  540. else if (input.substr(0,6) == "/kick ") {
  541. tcp.kick((char*)input.substr(6,input.length()-6).c_str());
  542. }
  543. else if (input.substr(0,5) == "/ban ") {
  544. tcp.ban((char*)input.substr(5,input.length()-5).c_str(),TRUE);
  545. }
  546. else if (input.substr(0,7) == "/unban ") {
  547. tcp.ban((char*)input.substr(7,input.length()-7).c_str(),FALSE);
  548. }
  549. else if (input.substr(0,9) == "/silence ") {
  550. int s = input.find(" ",9);
  551. tcp.silence((char*)input.substr(9,(s-9)).c_str(),atoi(input.substr(s,input.length()-s).c_str()));
  552. }
  553. else if (input.substr(0,6) == "/auth ") {
  554. if (input.substr(6,4) == "add ") {
  555. tcp.auth(0,(char*)input.substr(10,input.length()-10).c_str());
  556. }
  557. if (input.substr(6,7) == "delete ") {
  558. tcp.auth(1,(char*)input.substr(13,input.length()-13).c_str());
  559. }
  560. if (input.substr(6,6) == "enable") {tcp.auth(2);}
  561. if (input.substr(6,7) == "disable") {tcp.auth(3);}
  562. if (input.substr(6,4) == "help") {
  563. string helpinfo;
  564. helpinfo = "Channel Authorization Commands:\n";
  565. helpinfo += "\t/auth add [user]\t\t\t\tAuthorize 'user' in the current channel.\n";
  566. helpinfo += "\t/auth delete [user]\t\t\tDelete 'user' from current channel authorization.\n";
  567. helpinfo += "\t/auth enable\t\t\t\tAllow only authorized users in the channel.\n";
  568. helpinfo += "\t/auth disable\t\t\t\tAllow any users in the channel.\n";
  569. helpinfo += "\t/auth help\t\t\t\t\tShow this help information.";
  570. scr.paint_msg(helpinfo);
  571. }
  572. }
  573. else if (input.substr(0,9) == "/promote ") {
  574. tcp.mote((char*)input.substr(9,input.length()-9).c_str(),true);
  575. }
  576. else if (input.substr(0,8) == "/demote ") {
  577. tcp.mote((char*)input.substr(8,input.length()-8).c_str(),false);
  578. }
  579. else if (input.substr(0,9) == "/password") {
  580. if (input.length() > 9) {
  581. tcp.password((char*)input.substr(10,input.length()-10).c_str());
  582. }
  583. else { tcp.password((char*)"");}
  584. }
  585. else if (input.substr(0,4) == "/afk") {
  586. if (input.length() > 4) {
  587. tcp.avail(1,(char*)input.substr(5,input.length()-5).c_str());
  588. }
  589. else { tcp.avail(1,(char*)"Away from Keyboard"); }
  590. }
  591. else if (input.substr(0,4) == "/dnd") {
  592. if (input.length() > 4) {
  593. tcp.avail(2,(char*)input.substr(5,input.length()-5).c_str());
  594. }
  595. else { tcp.avail(2,(char*)"Do Not Disturb"); }
  596. }
  597. else if (input.substr(0,10) == "/available") {
  598. tcp.avail(0, (char*)"chat_command_available_message");
  599. }
  600. else if (input.length() != 0 && input[0] != '/' && scr.curchan != 0) {
  601. tcp.sendtext((char*)input.c_str(), input.length());
  602. }
  603. //Handle Right Clicks
  604. if (eventrecord.event != NULL) {
  605. ds.flush();
  606. char* tid = nick2id(eventrecord.args);
  607. if (tid != "-1") {
  608. if (eventrecord.event == "stats") {
  609. scr.statwindow(eventrecord.args);
  610. }
  611. else if (eventrecord.event == "whois") {
  612. input = "/whois " + (string)eventrecord.args;
  613. tcp.whois((char*)input.c_str(),input.length());
  614. }
  615. else if (eventrecord.event == "msg") {
  616. scr.privchat(eventrecord.args,FALSE);
  617. tcp.storage[tcp.numchan].name = eventrecord.args;
  618. tcp.storage[tcp.numchan].id = (char*)"privchat";
  619. tcp.numchan++;
  620. }
  621. else if (eventrecord.event == "whisper") {
  622. input = "/w " + (string)eventrecord.args + " ";
  623. scr.writeinput((char*)input.c_str());
  624. }
  625. else if (eventrecord.event == "buddy") {
  626. buddy(scr.id,tid,(char*)cookie.c_str(),TRUE,eventrecord.args);
  627. string out = "Username " + (string)eventrecord.args + " added to buddylist.";
  628. scr.paint_msg(out);
  629. scr.buddyupdate();
  630. }
  631. else if (eventrecord.event == "rbuddy") {
  632. buddy(scr.id,tid,(char*)cookie.c_str(),FALSE);
  633. string out = "Username " + (string)eventrecord.args + " removed from buddylist.";
  634. scr.paint_msg(out);
  635. scr.buddyupdate();
  636. }
  637. else if (eventrecord.event == "ignore") {
  638. ignore(scr.id,tid,NULL,(char*)cookie.c_str(),TRUE);
  639. string out = "Username " + (string)eventrecord.args + " set to ignore.";
  640. scr.paint_msg(out);
  641. }
  642. else if (eventrecord.event == "ban") {
  643. ban(scr.id,tid,NULL,(char*)cookie.c_str(),TRUE);
  644. string out = "Username " + (string)eventrecord.args + " successfully banned.";
  645. scr.paint_msg(out);
  646. }
  647. }
  648. eventrecord.event = NULL;
  649. eventrecord.args = (char*)"";
  650. }
  651. //Handle closing channels
  652. if (channelexit != -1) {
  653. tcp.leavech(channelexit);
  654. channelexit = -1;
  655. }
  656. //Receive any pending packets
  657. tcp.rwrap();
  658. if (strlen(status) > 0) {
  659. retval = statushandler();
  660. if (retval == 1) {scr.statwindow(NULL);}
  661. if (retval == 4) {scr.setupwindow();}
  662. else {break;}
  663. }
  664. }
  665. }
  666. }
  667. }
  668.  
  669. return 0;
  670. }
Add Comment
Please, Sign In to add comment