0009-ngircd-Update-protocol-module-for-current-Anope-1.9.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. From e74a5303f2357f4a9915bb91038a2e326323db3c Mon Sep 17 00:00:00 2001
  2. From: Alexander Barton <alex@barton.de>
  3. Date: Fri, 25 Nov 2011 19:16:37 +0100
  4. Subject: [PATCH 09/16] ngircd: Update protocol module for current Anope 1.9
  5. GIT
  6. This changes are rquired by:
  7. - b14f5ea88: Fixed accidentally clearing botmodes when joins are sent
  8. - cef3eb78d: Remove send_cmd and replace it with a stringstream
  9. - ddc3c2f38: Added options:nonicknameownership config option
  10. ---
  11. modules/protocol/ngircd.cpp | 54 ++++++++++++++++++++++--------------------
  12. 1 files changed, 28 insertions(+), 26 deletions(-)
  13. diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
  14. index 2774168..55cb8d7 100644
  15. --- a/modules/protocol/ngircd.cpp
  16. +++ b/modules/protocol/ngircd.cpp
  17. @@ -54,16 +54,22 @@ class ngIRCdProto : public IRCDProto
  18. void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf)
  19. {
  20. - send_cmd(source ? source->nick : Config->ServerName, "WALLOPS :%s", buf.c_str());
  21. + UplinkSocket::Message(source ? source->nick : Config->ServerName) << "WALLOPS :" << buf;
  22. }
  23. - void SendJoin(User *user, Channel *c, ChannelStatus *status)
  24. + void SendJoin(User *user, Channel *c, const ChannelStatus *status)
  25. {
  26. - send_cmd(user->nick, "JOIN %s", c->name.c_str());
  27. + UplinkSocket::Message(user->nick) << "JOIN " << c->name;
  28. if (status)
  29. {
  30. + /* First save the channel status incase uc->Status == status */
  31. ChannelStatus cs = *status;
  32. - status->ClearFlags();
  33. + /* If the user is internally on the channel with flags, kill them so that
  34. + * the stacker will allow this.
  35. + */
  36. + UserContainer *uc = c->FindUser(user);
  37. + if (uc != NULL)
  38. + uc->Status->ClearFlags();
  39. BotInfo *setter = findbot(user->nick);
  40. for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
  41. @@ -74,18 +80,18 @@ class ngIRCdProto : public IRCDProto
  42. void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf)
  43. {
  44. - send_cmd(source ? source->nick : Config->ServerName, "KILL %s :%s", user->nick.c_str(), buf.c_str());
  45. + UplinkSocket::Message(source ? source->nick : Config->ServerName) << "KILL " << user->nick << " :" << buf;
  46. }
  47. /* SERVER name hop descript */
  48. void SendServer(const Server *server)
  49. {
  50. - send_cmd("", "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
  51. + UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
  52. }
  53. void SendConnect()
  54. {
  55. - send_cmd("", "PASS %s 0210-IRC+ Anope|%s:CLHSo P", Config->Uplinks[CurrentUplink]->password.c_str(), Anope::VersionShort().c_str());
  56. + UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " 0210-IRC+ Anope|" << Anope::VersionShort() << ":CLHSo P";
  57. /* Make myself known to myself in the serverlist */
  58. SendServer(Me);
  59. /* finish the enhanced server handshake and register the connection */
  60. @@ -98,56 +104,52 @@ class ngIRCdProto : public IRCDProto
  61. Anope::string modes = "+" + u->GetModes();
  62. XLine x(u->nick, "Reserved for services");
  63. ircdproto->SendSQLine(NULL, &x);
  64. - send_cmd(Config->ServerName, "NICK %s 1 %s %s 1 %s :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), modes.c_str(), u->realname.c_str());
  65. + UplinkSocket::Message(Config->ServerName) << "NICK " << u->nick << " 1 " << u->GetIdent() << " " << u->host << " 1 " << modes << " :" << u->realname;
  66. }
  67. void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf)
  68. {
  69. if (!buf.empty())
  70. - send_cmd(bi->nick, "PART %s :%s", chan->name.c_str(), buf.c_str());
  71. + UplinkSocket::Message(bi->nick) << "PART " << chan->name << " :" << buf;
  72. else
  73. - send_cmd(bi->nick, "PART %s", chan->name.c_str());
  74. + UplinkSocket::Message(bi->nick) << "PART " << chan->name;
  75. }
  76. void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf)
  77. {
  78. -Log(LOG_DEBUG) << "SendModeInternal 1";
  79. - send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", dest->name.c_str(), buf.c_str());
  80. + UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "MODE " << dest->name << " " << buf;
  81. }
  82. void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf)
  83. {
  84. -Log(LOG_DEBUG) << "SendModeInternal 2";
  85. - send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str());
  86. + UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "MODE " << u->nick << " " << buf;
  87. }
  88. void SendKickInternal(const BotInfo *bi, const Channel *chan, const User *user, const Anope::string &buf)
  89. {
  90. if (!buf.empty())
  91. - send_cmd(bi->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf.c_str());
  92. + UplinkSocket::Message(bi->nick) << "KICK " << chan->name << " " << user->nick << " :" << buf;
  93. else
  94. - send_cmd(bi->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
  95. + UplinkSocket::Message(bi->nick) << "KICK " << chan->name << " " << user->nick;
  96. }
  97. - void SendNoticeChanopsInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf)
  98. + void SendChannel(Channel *c)
  99. {
  100. - send_cmd(source->nick, "NOTICE @%s :%s", dest->name.c_str(), buf.c_str());
  101. + Anope::string modes = c->GetModes(true, true);
  102. + UplinkSocket::Message(Config->ServerName) << "CHANINFO " << c->name << " +" << modes;
  103. }
  104. - /* INVITE */
  105. - void SendInvite(BotInfo *source, const Anope::string &chan, const Anope::string &nick)
  106. + void SendTopic(BotInfo *bi, Channel *c)
  107. {
  108. - send_cmd(source->nick, "INVITE %s %s", nick.c_str(), chan.c_str());
  109. + UplinkSocket::Message(bi->nick) << "TOPIC " << c->name << " :" << c->topic;
  110. }
  111. - void SendChannel(Channel *c)
  112. + void SendLogin(User *u)
  113. {
  114. - Anope::string modes = c->GetModes(true, true);
  115. - send_cmd(Config->ServerName, "CHANINFO %s +%s", c->name.c_str(), modes.c_str());
  116. }
  117. - void SendTopic(BotInfo *bi, Channel *c)
  118. +
  119. + void SendLogout(User *u)
  120. {
  121. - send_cmd(bi->nick, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
  122. }
  123. };
  124. --
  125. 1.7.8.3