int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam) { MCONTACT hContact = lParam; char *szProto = GetContactProto(hContact); if (!hContact || !szProto || mir_strcmpi(szProto, m_szModuleName)) return 0; if (isChatRoom(hContact)) return 0; if (getByte(hContact, "DCC", 0) != 0) return 0; DBVARIANT dbv; if (!getTString(hContact, "Default", &dbv)) { if (IsChannel(dbv.ptszVal)) { db_free(&dbv); return 0; } db_free(&dbv); } OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.flags = ODPF_DONTTRANSLATE; odp.pszTitle = m_szModuleName; odp.hIcon = NULL; odp.dwInitParam = (LPARAM)this; odp.hInstance = hInst; odp.position = -1900000000; odp.pfnDlgProc = UserDetailsDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO); odp.pszTitle = m_szModuleName; UserInfo_AddPage(wParam, &odp); return 0; }
MCONTACT CIrcProto::CList_FindContact(CONTACT *user) { if (!user || !user->name) return 0; TCHAR* lowercasename = mir_tstrdup(user->name); CharLower(lowercasename); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (isChatRoom(hContact)) continue; MCONTACT hContact_temp = NULL; ptrT DBNick(getTStringA(hContact, "Nick")); ptrT DBUser(getTStringA(hContact, "UUser")); ptrT DBHost(getTStringA(hContact, "UHost")); ptrT DBDefault(getTStringA(hContact, "Default")); ptrT DBWildcard(getTStringA(hContact, "UWildcard")); if (DBWildcard) CharLower(DBWildcard); if (IsChannel(user->name)) { if (DBDefault && !lstrcmpi(DBDefault, user->name)) hContact_temp = (MCONTACT)-1; } else if (user->ExactNick && DBNick && !lstrcmpi(DBNick, user->name)) hContact_temp = hContact; else if (user->ExactOnly && DBDefault && !lstrcmpi(DBDefault, user->name)) hContact_temp = hContact; else if (user->ExactWCOnly) { if (DBWildcard && !lstrcmpi(DBWildcard, lowercasename) || (DBWildcard && !lstrcmpi(DBNick, lowercasename) && !WCCmp(DBWildcard, lowercasename)) || (!DBWildcard && !lstrcmpi(DBNick, lowercasename))) { hContact_temp = hContact; } } else if (_tcschr(user->name, ' ') == 0) { if ((DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) || DBWildcard && WCCmp(DBWildcard, lowercasename)) && (WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host))) { hContact_temp = hContact; } } if (hContact_temp != NULL) { mir_free(lowercasename); if (hContact_temp != (MCONTACT)-1) return hContact_temp; return 0; } } mir_free(lowercasename); return 0; }
void CommandDEVOICE::Parser() { if (Parameters.size() < 1) { LocalBot->SendNotice(Source, "SYNTAX: " + Syntax); return; } if (!IsChannel(Parameters[0])) { LocalBot->SendNotice(Source, "Invalid channel"); return; } // Is this channel registered? SqlChannel* l_SqlChannel = SQL::Interface.FindChannel(Parameters[0]); if (NULL == l_SqlChannel) { LocalBot->SendNotice(Source, "Channel " + Parameters[0] + " doesn't appear to be registered."); return; } // Does the channel exist? Channel* l_Channel = Network::Interface.FindChannel(Parameters[0]); if (NULL == l_Channel) { LocalBot->SendNotice(Source, "Can't find channel " + Parameters[0] + " in Network database"); return; } // Are we in that channel? if (!l_Channel->IsChannelClient(&LocalBot->theClient)) { LocalBot->SendNotice(Source, "I'm not in " + Parameters[0]); return; } if (!SQL::Interface.HasEnoughAccess(Source, l_Channel, Command::Level::UP)) { LocalBot->SendNotice(Source, "You don't have enough access to perform this command"); return; } // If not nicks provided, up the source. if (Parameters.size() == 1) LocalBot->TakeVoice(l_Channel, Source->GetNickName()); else LocalBot->TakeVoice(l_Channel, Parameters.assamble(1)); }
void DoMode(struct Channel *chptr, char *modes, int joinpart) { #ifdef SAVE_TS struct Chanlist *chanptr; #endif if (!chptr || !modes) return; #ifdef SAVE_TS chanptr = IsChannel(chptr->name); #ifndef HYBRID_ONLY /* no need to join on hybrid */ if (joinpart && !chanptr) /* make sure its not already a monitored channel */ os_join(chptr); #endif toserv(":%s MODE %s %s\n", n_OperServ, chptr->name, modes); UpdateChanModes(Me.osptr, n_OperServ, chptr, modes); #ifndef HYBRID_ONLY if (joinpart && !chanptr) os_part(chptr); #endif #else toserv(":%s MODE %s %s\n", Me.name, chptr->name, modes); UpdateChanModes(0, Me.name, chptr, modes); #endif /* SAVE_TS */ } /* DoMode() */
void CommandDOWN::Parser() { // Is this channel registered? SqlChannel* l_SqlChannel = SQL::Interface.FindChannel(Parameters[0]); if (NULL == l_SqlChannel) { LocalBot->SendNotice(Source, "Channel " + Parameters[0] + " doesn't appear to be registered."); return; } if (!IsChannel(Parameters[0])) { LocalBot->SendNotice(Source, "Invalid channel"); return; } // Does the channel exist? Channel* l_Channel = Network::Interface.FindChannel(Parameters[0]); if (NULL == l_Channel) { LocalBot->SendNotice(Source, "Can't find channel " + Parameters[0] + " in Network database"); return; } // Are we in that channel? if (!l_Channel->IsChannelClient(&LocalBot->theClient)) { LocalBot->SendNotice(Source, "I'm not in " + Parameters[0]); return; } if (!SQL::Interface.HasEnoughAccess(Source, l_Channel, Command::Level::DOWN)) { LocalBot->SendNotice(Source, "You don't have enough access to perform this command"); return; } LocalBot->TakeOP(l_Channel, Source->GetNickName()); }
int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam) { char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, lParam, 0); HANDLE hContact = (HANDLE) lParam; if ( !hContact || !szProto || lstrcmpiA( szProto, m_szModuleName )) return 0; if ( getByte( hContact, "ChatRoom", 0 ) != 0 ) return 0; if ( getByte( hContact, "DCC", 0 ) != 0 ) return 0; DBVARIANT dbv; if ( !getTString( hContact, "Default", &dbv )) { if ( IsChannel( dbv.ptszVal )) { DBFreeVariant( &dbv ); return 0; } DBFreeVariant(&dbv); } OPTIONSDIALOGPAGE odp = { 0 }; odp.cbSize = sizeof(odp); odp.flags = ODPF_DONTTRANSLATE; odp.pszTitle = m_szModuleName; odp.hIcon = NULL; odp.dwInitParam = ( LPARAM )this; odp.hInstance = hInst; odp.position = -1900000000; odp.pfnDlgProc = UserDetailsDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO); odp.pszTitle = m_szModuleName; CallService( MS_USERINFO_ADDPAGE, wParam, (LPARAM) & odp); return 0; }
void CommandMODINFO::Parser() { if (Parameters.size() != 4) { LocalBot->SendNotice(Source, "SYNTAX: " + Syntax); return; } if (!IsChannel(Parameters[0])) { LocalBot->SendNotice(Source, "Invalid channel"); return; } SqlChannel* l_SqlChannel = SQL::Interface.FindChannel(Parameters[0]); if (NULL == l_SqlChannel) { LocalBot->SendNotice(Source, "Channel " + Parameters[0] + " is not registered."); return; } if (!SQL::Interface.HasEnoughAccess(Source, Parameters[0], Command::Level::MODINFO) && !SQL::Interface.HasEnoughAccess(Source, "*", Command::Level::MODINFO)) { LocalBot->SendNotice(Source, "You don't have enough access to do that."); return; } SqlUser* l_SqlUser = SQL::Interface.FindUser(Parameters[2]); if (l_SqlUser == NULL) { LocalBot->SendNotice(Source, "I don't know who " + Parameters[2] + " is."); return; } SqlChannelAccess* l_SqlChannelAccess = SQL::Interface.FindChannelAccess(l_SqlUser->getID(), l_SqlChannel->getID()); if (l_SqlChannelAccess == NULL) { LocalBot->SendNotice(Source, "User " + Parameters[2] + " does not have access in " + Parameters[0] + "."); return; } if (SQL::Interface.GetAccessLevel(Source, l_SqlChannel->getID()) < l_SqlChannelAccess->getLevel()) { LocalBot->SendNotice(Source, "Cannot modify access of user that has equal or higher access than you."); return; } if (Parameters[1] == "access") { if (SQL::Interface.GetAccessLevel(Source, l_SqlChannel->getID()) <= l_SqlChannelAccess->getLevel()) { LocalBot->SendNotice(Source, "Cannot modify access of user that has equal or higher access than you."); return; } if (!IsDigit(Parameters[3])) { LocalBot->SendNotice(Source, "Bogus access level."); return; } unsigned int l_level = StringToInt(Parameters[3]); if (l_level > 500 || l_level == 0) { LocalBot->SendNotice(Source, "Bogus access level number."); return; } if (SQL::Interface.GetAccessLevel(Source, l_SqlChannel->getID()) <= l_level) { LocalBot->SendNotice(Source, "Access level needs to be less that yours."); return; } l_SqlChannelAccess->setLevel(l_level); LocalBot->SendNotice(Source, "Set access level of " + Parameters[2] + " to " + Parameters[3] + " in " + Parameters[0] + "."); } else if (Parameters[1] == "automode") { if (SQL::Interface.GetAccessLevel(Source, l_SqlChannel->getID()) < l_SqlChannelAccess->getLevel()) { LocalBot->SendNotice(Source, "Cannot modify access of user that has higher access than you."); return; } if (Parameters[3] == "op") l_SqlChannelAccess->setAutomode(SqlChannelAccess::AUTOMODE_OP); else if (Parameters[3] == "voice") l_SqlChannelAccess->setAutomode(SqlChannelAccess::AUTOMODE_VOICE); else if (Parameters[3] == "none") l_SqlChannelAccess->setAutomode(SqlChannelAccess::AUTOMODE_NONE); else { LocalBot->SendNotice(Source, "That's an invalid AutoMode"); return; } LocalBot->SendNotice(Source, "Set automode of " + Parameters[2] + " to " + Parameters[3] + " in " + Parameters[0] + "."); } else { LocalBot->SendNotice(Source, "SYNTAX: " + Syntax); return; } l_SqlChannelAccess->update(); }
HANDLE CIrcProto::CList_FindContact (CONTACT* user) { if ( !user || !user->name ) return 0; TCHAR* lowercasename = mir_tstrdup( user->name ); CharLower(lowercasename); DBVARIANT dbv1; DBVARIANT dbv2; DBVARIANT dbv3; DBVARIANT dbv4; DBVARIANT dbv5; for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if ( isChatRoom(hContact)) continue; HANDLE hContact_temp = NULL; TCHAR* DBDefault = NULL; TCHAR* DBNick = NULL; TCHAR* DBWildcard = NULL; TCHAR* DBUser = NULL; TCHAR* DBHost = NULL; if ( !getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal; if ( !getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal; if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal; if ( !getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal; if ( !getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal; if ( DBWildcard ) CharLower( DBWildcard ); if ( IsChannel( user->name )) { if ( DBDefault && !lstrcmpi( DBDefault, user->name )) hContact_temp = (HANDLE)-1; } else if ( user->ExactNick && DBNick && !lstrcmpi( DBNick, user->name )) hContact_temp = hContact; else if ( user->ExactOnly && DBDefault && !lstrcmpi( DBDefault, user->name )) hContact_temp = hContact; else if ( user->ExactWCOnly ) { if ( DBWildcard && !lstrcmpi( DBWildcard, lowercasename ) || ( DBWildcard && !lstrcmpi( DBNick, lowercasename ) && !WCCmp( DBWildcard, lowercasename )) || ( !DBWildcard && !lstrcmpi(DBNick, lowercasename))) { hContact_temp = hContact; } } else if ( _tcschr(user->name, ' ' ) == 0 ) { if (( DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) || DBWildcard && WCCmp( DBWildcard, lowercasename )) && ( WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host))) { hContact_temp = hContact; } } if ( DBDefault ) db_free(&dbv1); if ( DBNick ) db_free(&dbv2); if ( DBWildcard ) db_free(&dbv3); if ( DBUser ) db_free(&dbv4); if ( DBHost ) db_free(&dbv5); if ( hContact_temp != NULL ) { mir_free(lowercasename); if ( hContact_temp != (HANDLE)-1 ) return hContact_temp; return 0; } } mir_free(lowercasename); return 0; }