home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Advanced_I3550511162001.psc / Module1.bas < prev   
Encoding:
BASIC Source File  |  2001-11-17  |  14.2 KB  |  484 lines

  1. Attribute VB_Name = "Module1"
  2. 'Option Explicit
  3. Dim BinChr As String: Dim xChr As String: Dim xResult As String: Dim Z As Integer: Dim NewChr As Integer: Dim xB As Integer: Dim xB2 As Integer
  4. Dim TmpStr As String: Dim NewBin As String: Dim C As Integer: Dim DD As Integer: Dim EE As Integer
  5. Dim BinArray(7) As String: Dim User As String: Dim Password As String: Dim i As Integer 'Declarations
  6. Dim Letters As String: Dim comm As String: Dim DataBuild As String
  7.  
  8. Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
  9. Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
  10. Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
  11. Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
  12. Const MF_BYPOSITION = &H400&
  13. Const MF_REMOVE = &H1000&
  14.  
  15. Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
  16.  
  17. Public Const NIM_ADD = &H0
  18. Public Const NIM_MODIFY = &H1
  19. Public Const NIM_DELETE = &H2
  20. Public Const NIF_MESSAGE = &H1
  21. Public Const NIF_ICON = &H2
  22. Public Const NIF_TIP = &H4
  23. Public Const WM_MOUSEMOVE = &H200
  24. Public Const WM_LBUTTONDOWN = &H201
  25. Public Const WM_LBUTTONUP = &H202
  26. Public Const WM_LBUTTONDBLCLK = &H203
  27. Public Const WM_RBUTTONDOWN = &H204
  28. Public Const WM_RBUTTONUP = &H205
  29. Public Const WM_RBUTTONDBLCLK = &H206
  30. Public Const HWND_TOPMOST = -1
  31.  
  32. Public nid As NOTIFYICONDATA
  33.  
  34. Public Type NOTIFYICONDATA
  35.     cbSize As Long
  36.     hwnd As Long
  37.     uId As Long
  38.     uFlags As Long
  39.     uCallBackMessage As Long
  40.     hIcon As Long
  41.     szTip As String * 64
  42. End Type
  43.  
  44. Global isWhois As Boolean
  45. Global LogFile As String
  46.  
  47. Public Function xMenu(FormName As Form)
  48.     
  49. Dim hSysMenu As Long, nCnt As Long
  50.  
  51.     hSysMenu = GetSystemMenu(FormName.hwnd, False)
  52.  
  53.     If hSysMenu Then
  54.         nCnt = GetMenuItemCount(hSysMenu)
  55.         If nCnt Then
  56.             RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
  57.             RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE
  58.             DrawMenuBar FormName.hwnd
  59.         End If
  60.     End If
  61.  
  62. End Function
  63.  
  64. Public Function Ascii(BinText As String) 'Convert Binary to ASCII
  65.  
  66.     For xB = 1 To Len(BinText)
  67.         BinChr = Mid(BinText, xB, 8)
  68.         Z = 128: NewChr = 0
  69.  
  70.         For xB2 = 1 To 8
  71.             xChr = Mid(BinChr, xB2, 1)
  72.             If xChr = "1" Then
  73.                 NewChr = NewChr + Z
  74.                 Z = Z / 2
  75.             Else
  76.                 Z = Z / 2
  77.             End If
  78.         Next xB2
  79.  
  80.         xResult = xResult & Chr(NewChr)
  81.         xB = xB + 7
  82.  
  83.     Next xB
  84.  
  85.     Ascii = xResult: xResult = ""
  86.  
  87. End Function
  88.  
  89. Public Function Binary(AscText As String) 'Convert ASCII to Binary
  90.     
  91.     For C = 1 To Len(AscText)
  92.     
  93.         DD = Asc(Mid(AscText, C, 1)): BinArray(7) = DD Mod 2
  94.         
  95.         DD = DD \ 2: BinArray(6) = DD Mod 2
  96.         DD = DD \ 2: BinArray(5) = DD Mod 2
  97.         DD = DD \ 2: BinArray(4) = DD Mod 2
  98.         DD = DD \ 2: BinArray(3) = DD Mod 2
  99.         DD = DD \ 2: BinArray(2) = DD Mod 2
  100.         DD = DD \ 2: BinArray(1) = DD Mod 2
  101.         DD = DD \ 2: BinArray(0) = DD Mod 2
  102.  
  103.         For EE = 0 To UBound(BinArray)
  104.             TmpStr = TmpStr + BinArray(EE)
  105.         Next EE
  106.  
  107.         NewBin = NewBin + TmpStr: TmpStr = ""
  108.  
  109.     Next C
  110.  
  111.     Binary = NewBin: NewBin = ""
  112.  
  113. End Function
  114.  
  115. Public Function Box(xPos As Integer, yPos As Integer, Width As Integer, Height As Integer, Border As Integer)
  116.  
  117. 'Nifty function i made for creating ansi instructions for GUI, good for telnet servers.
  118.  
  119. Dim TopLeft As String: Dim TopRight As String
  120. Dim BottomLeft As String: Dim BottomRight As String
  121. Dim AcrossTop As String: Dim AcrossBottom As String
  122. Dim DownLeft As String: Dim DownRight As String
  123. Dim TheBoxData
  124.  
  125. If Border = 1 Then
  126.     TopLeft = Chr(218): TopRight = Chr(191)
  127.     BottomLeft = Chr(192): BottomRight = Chr(217)
  128.     AcrossTop = Chr(196): AcrossBottom = Chr(196)
  129.     DownLeft = Chr(179): DownRight = Chr(179)
  130. End If
  131.  
  132. If Border = 2 Then
  133.     TopLeft = Chr(201): TopRight = Chr(187)
  134.     BottomLeft = Chr(200): BottomRight = Chr(188)
  135.     AcrossTop = Chr(205): AcrossBottom = Chr(205)
  136.     DownLeft = Chr(186): DownRight = Chr(186)
  137. End If
  138.  
  139. If Border = 3 Then
  140.     TopLeft = Chr(220): TopRight = Chr(220)
  141.     BottomLeft = Chr(223): BottomRight = Chr(223)
  142.     AcrossTop = Chr(220): AcrossBottom = Chr(223)
  143.     DownLeft = Chr(221): DownRight = Chr(222)
  144. End If
  145.  
  146. If Border = 4 Then
  147.     TopLeft = Chr(219): TopRight = Chr(219)
  148.     BottomLeft = Chr(219): BottomRight = Chr(219)
  149.     AcrossTop = Chr(219): AcrossBottom = Chr(219)
  150.     DownLeft = Chr(219): DownRight = Chr(219)
  151. End If
  152.  
  153.     TheBoxData = TheBoxData & Mv(xPos, yPos) & TopLeft
  154.  
  155.         For i = 1 To Width - 2
  156.             TheBoxData = TheBoxData & AcrossTop
  157.             DoEvents
  158.         Next
  159.  
  160.     TheBoxData = TheBoxData & Mv(xPos, Width + yPos - 1) & TopRight
  161.  
  162.     TheBoxData = TheBoxData & Mv(Height + xPos - 1, yPos) & BottomLeft
  163.  
  164.         For i = 1 To Width - 2
  165.             TheBoxData = TheBoxData & AcrossBottom
  166.             DoEvents
  167.         Next
  168.  
  169.     TheBoxData = TheBoxData & Mv(Height + xPos - 1, yPos + Width - 1) & BottomRight
  170.  
  171.         For i = 1 To Height - 2
  172.             TheBoxData = TheBoxData & Mv(xPos + i, yPos) & DownLeft
  173.             DoEvents
  174.         Next
  175.  
  176.         For i = 1 To Height - 2
  177.             TheBoxData = TheBoxData & Mv(xPos + i, Width + yPos - 1) & DownRight
  178.             DoEvents
  179.         Next
  180.  
  181. Box = TheBoxData
  182.  
  183. End Function
  184.  
  185. Function Mv(xPos As Integer, yPos As Integer)
  186.  
  187. Mv = "" & xPos & ";" & yPos & "H" 'ANSI code to move the cursors position.
  188.  
  189. End Function
  190.  
  191. Public Function l33t(ASCII_Code As String) 'A really stupid non-randomized not-so-slite speaker.
  192.  
  193.     Select Case ASCII_Code
  194.  
  195.         Case "a"
  196.             l33t = Chr(229)
  197.         
  198.         Case "b"
  199.             l33t = Chr(223)
  200.  
  201.         Case "c"
  202.             l33t = Chr(231)
  203.             
  204.         Case "d"
  205.             l33t = "╨"
  206.             
  207.         Case "e"
  208.             l33t = Chr(235)
  209.             
  210.         Case "i"
  211.             l33t = Chr(238)
  212.  
  213.         Case "l"
  214.             l33t = Chr(163)
  215.  
  216.         Case "n"
  217.             l33t = Chr(241)
  218.             
  219.         Case "o"
  220.             l33t = Chr(248)
  221.              
  222.         Case "u"
  223.             l33t = Chr(249)
  224.              
  225.         Case "x"
  226.             l33t = Chr(215)
  227.              
  228.         Case "A"
  229.             l33t = Chr(197)
  230.         
  231.         Case "C"
  232.             l33t = Chr(199)
  233.                      
  234.         Case "E"
  235.             l33t = Chr(203)
  236.  
  237.         Case "N"
  238.             l33t = Chr(209)
  239.  
  240.         Case "Y"
  241.             l33t = Chr(165)
  242.             
  243.         Case "U"
  244.             l33t = Chr(220)
  245.  
  246.         Case "I"
  247.             l33t = Chr(207)
  248.             
  249.         Case "O"
  250.             l33t = Chr(216)
  251.  
  252.         Case "?"
  253.             l33t = Chr(191)
  254.         
  255.         Case "!"
  256.             l33t = Chr(161)
  257.  
  258.         Case "0"
  259.             l33t = Chr(186)
  260.  
  261.         Case "1"
  262.             l33t = Chr(185)
  263.  
  264.         Case "2"
  265.             l33t = Chr(178)
  266.  
  267.         Case "3"
  268.             l33t = Chr(179)
  269.         
  270.         Case Else
  271.             l33t = LCase(ASCII_Code)
  272.         
  273.     End Select
  274.  
  275. End Function
  276.  
  277. Public Function Elite(Text As String) 'Second routine for eliterizing
  278.  
  279. For i = 1 To Len(Text)
  280.     Letters = Letters & l33t(Mid(Split(comm, "; ")(1), i, 1))
  281. Next
  282.  
  283. Letters = Replace(Letters, "╪╪", "╥╓")
  284. Letters = Replace(Letters, "°°", "≥÷")
  285. Letters = Replace(Letters, "╧╧", "╠╧")
  286. Letters = Replace(Letters, "εε", "∞∩")
  287. Letters = Replace(Letters, "╦╦", "╚╦")
  288. Letters = Replace(Letters, "δδ", "Φδ")
  289. Letters = Replace(Letters, "┼╦", Chr(198))
  290. Letters = Replace(Letters, "σδ", Chr(230))
  291. Letters = Replace(Letters, "εrτ", "∞«⌐")
  292. Letters = Replace(Letters, "╧r╟", "∞«⌐")
  293.  
  294. End Function
  295.  
  296. Public Function LoadLists() 'Load the user lists
  297.  
  298. LoadList Form4.AOP, "aop.ini"
  299. LoadList Form4.Admins, "admins.ini"
  300. LoadList Form4.Opers, "opers.ini"
  301. LoadList Form4.Users, "users.ini"
  302.  
  303. End Function
  304.  
  305. Public Function Msg(xChannel As String, Message As String)
  306.  
  307. Msg = "PRIVMSG " & xChannel & " :" & Message
  308.  
  309. End Function
  310.  
  311. Public Function OP(xChannel As String, Nickname As String)
  312.  
  313. OP = "MODE " & xChannel & " +o " & Nickname
  314.  
  315. End Function
  316.  
  317. Public Function DEOP(xChannel As String, Nickname As String)
  318.  
  319. DEOP = "MODE " & xChannel & " -o" & Nickname
  320.  
  321. End Function
  322.  
  323. Public Function Voice(xChannel As String, xNickname As String)
  324.  
  325. Send "MODE " & xChannel & " +v " & xNickname
  326.  
  327. End Function
  328.  
  329. Public Function Ban(xChannel As String, NicknameOrHost As String)
  330.  
  331. Ban = "MODE " & xChannel & " +b "
  332.  
  333.     If IsNumeric(Mid(NicknameOrHost, 1, 2)) = True Then
  334.         Ban = Ban & "*!*@" & NicknameOrHost
  335.     Else
  336.         Ban = Ban & NicknameOrHost
  337.     End If
  338.  
  339. End Function
  340.  
  341. Public Function unBan(Channel As String, Nickname As String)
  342.  
  343. unBan = "MODE " & Channel & " -b "
  344.  
  345.     If IsNumeric(Mid(Nickname, 1, 2)) = True Then
  346.         unBan = unBan & "*!*@" & Nickname
  347.     Else
  348.         unBan = unBan & Nickname
  349.     End If
  350.  
  351. End Function
  352.  
  353. Public Function Kick(xChannel As String, Nickname As String, Reason As String)
  354.  
  355. Kick = "KICK " & xChannel & " " & Nickname & " :" & Reason
  356.  
  357. End Function
  358.  
  359. Public Function Send(Data As String)
  360.  
  361. If Len(Data) < 500 Then
  362.     Form1.Sock1.SendData Data & vbCrLf
  363. End If
  364.  
  365. End Function
  366.  
  367. Public Function Register()
  368.  
  369.     Send "USER " & Form1.txtUser & " ? * :" & Form1.txtEmail
  370.     Send "NICK " & Form1.txtNick
  371.     Send Msg("nickserv@services.dal.net", "identify " & Password)
  372.     Send "JOIN #decode"
  373.  
  374. End Function
  375.  
  376. Public Function QUIT(QuitMessage As String)
  377.  
  378.         DoEvents
  379.     Send "QUIT :" & QuitMessage
  380.         DoEvents
  381.     Form1.Sock1.Close
  382.  
  383. Log "+CONNECTION LOST: " & Date & " - " & Time & " / " & Form1.IRCServer.Text
  384. Form1.IRCServer.Text = ""
  385.  
  386. End Function
  387.  
  388. Public Function IsInList(xControl As Control, SearchString As String)
  389.  
  390.     For i = 0 To xControl.ListCount
  391.  
  392.         If UCase(SearchString) = UCase(xControl.List(i)) Then
  393.             IsInList = 1
  394.             Exit For
  395.         Else
  396.             ring)
  397.  
  398. If aδis ControlI   hl.List(e Nicknameel AolI   hl.List(, ReIe " & Date & " - " & Tszate & " eGg) = UCase(xControl.List(i)) ThMxtannel As String, d "JOIGg)st(i)) ThMxtannel As StrinI       Case "a"
  399.   Gg) = TSm    Case h Stringckname,Rc Function DEOP(xCha≥÷")
  400. Let     Case To>. As String, Nickname As String)
  401.  
  402. oac Functi String, Nickname Amerinckserv@services.dal.nl AolI   String)
  403.  
  404. oac Functi Str3)
  405. Letters = Replace(Letters, "δδ"etteame Amerinckserv@services.dal.nl AolI  
  406.  
  407. oac Fun
  408.  
  409. oacfList(doac Fun
  410.  
  411. lI  As String, Reason As String)
  412.  
  413. KicklI  Oo Amerinckserv@services.dal.nl AolI  
  414.  
  415. oac Frs, @servicserv@sertps Stri- Oo ╧lervicpne "JOIsl AolI  
  416.  
  417. oac FunI ╧lervicpne "JOIsl AolI  
  418.  
  419. o     Clcpne  u=r &1I  
  420.  
  421. oa  As String, Rescserv@sertp String)
  422.  
  423. oac Functi Str wl AolI Roac Fuhannl2sCZrtpe
  424. I Ca      ring)
  425.  
  426. If aδis ControlI   hl.List(e NicknsCZrtpe
  427. I Ca      ring)
  428.  
  429. If aδ
  430.   Gg) nb & Date & " - " & Time kserv@services.dauc VCearc
  431.  
  432. oacfList(doac Fu 0BIsl AolIo*lLn5Cl.ListCooNickname
  433.  
  434. End FuncE "MODE "
  435. e To>. As String, Nickname A(nd FuncE "MODE "
  436. unI ╧lervicpne "JOIsl Ao StrKFuncEs oO2CooNecpne "J. As
  437. oac FunI ╧lervicpne "JOIl0s, "δδ", "Φrol.List(i))uncaarchString As , "Φod   h °d "U!caaontrol.List(i)) TcCDnction ontrol.LihN & " +v " & xNicknameunI ╧lervicpne "JOIlst(i)) ThMxtanne" & mde"
  438.  
  439. End Functirf"nb      oknameT3Oe0eate & " - " & Time & " / " & JOIl0s, "δδ", "Φ cOe & End FunctisrEnd FuncE "MODE "
  440. e To>. As Str2M.Listc", "Φ -3rEnd FuncE "MODE d   h _,rrin " +v " & xNicknameunIrokn6
  441.  = ""
  442.  
  443. Fa6r2M.mte "JOIltTime OThMxtas& JOIl0s,OND
  444.  
  445. Fa6mw     Ban = BanT3e.
  446. DNecpne "J. As
  447. oac FunI ╧lervicpne "JOIl0s", "Φ -3rEnd FuncE "MODE d   h _xOWices.daForrinG""Φ -3rEnd Fus, = BaFunes.dal.nl AolI  
  448.  
  449. oac Frs, @servicserv@sertps Stri- Oo ╧AolI  
  450. e "JservThkname As StrinNecpne "J. As
  451. oac FunI ╧lervicp)) Then
  452.            (i))uncaarpEnd Function
  453.  
  454. Puv& BaFunes = Replace(Letters, "δheBorm4.Users, "users.inica =e "!"
  455.   G""Φ -3rEnd Fus, = BaFunes.dal.nl AolI  
  456.  
  457. V3s
  458.   G"OaFuIW)nctirN2Aes.d As String)
  459.  
  460. OP = "MODE " &ring)
  461. OBorm4.2_Vav& B()
  462.  
  463. oac Functhac F',
  464.  
  465.  BnctE " &ring)
  466. o
  467. e "JservThkname BaFux Else
  468.         unrm4.2_Vav& B()
  469.  
  470. oac Functhac F',
  471.  
  472.  BnDE d   h _,  h _,rr(e,
  473.  
  474.  BnctE ".  
  475.  
  476.  BnDE d   h _,  h _,rr(e,
  477.  
  478.  BnctE ".  
  479.  
  480.  BV.Users, "users.inica =e "!"
  481. 2inica =e "!"
  482. 2inic
  483.  
  484. OP = "MODE ca =etCns, = BaFunes.dals2)
  485. OBorm4.2_Vav& B()
  486.  
  487. oac Func.Functi7AVtCnMenoac Fun
  488.  
  489.  
  490. oac Functhac sfh"faFunct
  491. oactflnReplaceug)
  492.  
  493. oac Functi v& B()r BnDE d   h D6laceug,1l3rvicserv@Isl5A=  coReame APNIPeIion onctflnReplaceug)
  494.  
  495. oac Functi v& B()r BnDE d  Z,nd  Z ReIe " & e As Strintrin DEOP(    oknameT3Oe0eeIe " &vi v& B()r(    oknameT3l5A=  coReame APNIPeoNe Auncthac F',
  496.  
  497.  BnctE " &ringmoReare(T9s4ntrin DEOP0se "U"
  498.     2=  coReame APNIPeIitTTcCDnct DEOP0se "U"
  499.  s]noac Fp7t  coR-9s "!"
  500. 2inic
  501.  
  502. OP = "MODE ca =etCnsimeT3Oe0eeIe07t  coR-9s "!)TODE cIn)7t  coBU = "" &,e0eeac F',
  503.  
  504.  BnctNE ca =etCnsimeT3Oe0eeIe07t  coR-9s "!)TODEC "U"DimeT kw9s "!"
  505. 2inC "!)TODEC "U"DimeT kw9s "!"
  506. Zr!)TOD ε "U"D _hcs' e As Strintrin DE _hcs' eknameT3Oe0eeIe " &mginameel AolI   hl.List( eknameT3Oe0eeIe " &mginameel Aol As StimeT kw9s -laceug)
  507. hAol As StimeT kw9    2=  coRnri- oReare(T9s4ntri6Li4tion
  508. e " &mginamee"List(e Nicknameel AolI   hl.L tring)
  509.  
  510. KicklI ee"ListEC4tion
  511. e " &mginamee"List(e Nicmeel AolI   hl.L trin0eate WpWMODE ca =etCnsimeT3O0"
  512. e To>. Ars.inica =e "!"o.L tring)
  513.  
  514. KicklI ee"ListEC4tionetters ="MOel A &mguel Aotionetters ="MOel A &mguel Aotionetters =" Aotionetters ="MOel A &mnMOelB"os Aotiove,o>. Ars.i!"o.L tring)
  515.  
  516. Kitri6Liogg=" Aotionesohannel & " +v " & xNs7rMBmeelogg=" Aotionesohannel & " +v " & xNs7rMBmeelogg=" Aokym4.L= Ao╠eT.4r= Ao╠euo.L tring)
  517.  
  518. KicklI eL"∞«⌐")
  519.  
  520. En/7n9a, = BaFu╚tsContro& x,okym4.)cwFu╚tsContro& x,TDop +vT3Oe0eeIe " &mginame  hl.L trin0eateontro& x,Te  hl.L trin0eateontro& x,Te  hl.L tr (m +vT3Oe0eeIe " &mginame  hl.L ,TeNKE Then
  521. E   u"lic FuncFun
  522.  
  523. oacfList(doac Fun
  524.  
  525.  Funcn(m el A &mgxho"pf.te " &mginameih4txho"pf.te o>. Clε "U"D _hcs' e As Stri    Ame APNIPeoNerv@sertps Stoun0eateontro& x,Te  hl.L trin0ea!"o.L tring)
  526.  
  527.  4ti s Sto Ars.in& e As Strintrin DEtoun#wprintro& x