home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / sviluppo / rxmui / examples / bang.amirx < prev    next >
Text File  |  1999-12-21  |  8KB  |  275 lines

  1. /**/
  2.  
  3. parse arg n
  4.  
  5. options results
  6.  
  7. signal on halt
  8. signal on break_c
  9.  
  10. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  11. if AddLibrary("rxmui.library","rxsocket.library")~=0 then exit
  12.  
  13. call rxmuiopt("debugmode showerr")
  14.  
  15. call initAll(n)
  16. call handleApp
  17. exit
  18. /***********************************************************************/
  19. initAll: procedure expose globals.
  20. parse arg n
  21.     call createApp
  22.  
  23.     call set("mwin","open",1)
  24.     call getattr("mwin","open","o")
  25.     if o=0 then do
  26.         say "can't open window"
  27.         exit
  28.     end
  29.  
  30.     "GETCHANNEL"
  31.     global.ch=result
  32.     global.reasone = ""
  33.     global.MaskType = 0
  34.     call selected(n)
  35.     return
  36. /***********************************************************************/
  37. handleApp: procedure expose globals.
  38. ctrl_c=2**12
  39. s=0
  40. do forever
  41.     call handle("APP","H",s)
  42.     do i=0 to h.num-1
  43.         id=h.i
  44.         select
  45.             when id="QUIT" then exit
  46.             when id="GETNICK" then call selected
  47.             when id="MASKTYPE" then do
  48.                 global.banMask=makeMask()
  49.                 call set("banmask","contents",global.banMask)
  50.             end
  51.             when id="OP" then call op
  52.             when id="WHOIS" then call whois
  53.             when id="UINFO" then call UInfo
  54.             when id="DEOP" then call deop
  55.             when id="KICK" then call kick
  56.             when id="BAN" then call ban
  57.             when id="KBAN" then call kban
  58.             when id="TBAN" then call tban
  59.             otherwise nop
  60.         end
  61.     end
  62.     s=Wait(or(h.signals,ctrl_c))
  63.     if and(s,ctrl_c)>0 then exit
  64. end
  65. exit
  66. /***********************************************************************/
  67. err: procedure expose globals. sigl rxmuierror
  68. parse arg res
  69. say signl "["res"]"
  70.     say getrxmuistring(res) "in line" sigl-1 rxmuierror
  71.     exit
  72. /***********************************************************************/
  73. createApp: procedure expose globals.
  74.  
  75.     app.Title="Show"
  76.     app.Version="$VER: Show 1.0 (17.12.99)"
  77.     app.Copyright="©1999, alfie"
  78.     app.Author="alfie"
  79.     app.Description="RxMui Show"
  80.     app.Base="SHOW"
  81.     app.SubWindow="mwin"
  82.      mwin.ID="MAIN"
  83.      mwin.Title="RxMUI Show"
  84.      mwin.Contents="mgroup"
  85.       mgroup.horiz=1
  86.  
  87.        mgroup.0="sg"
  88.        sg.class="group"
  89.        sg.columns=2
  90.         sg.0=label("_Nick","double")
  91.         sg.1="ng"
  92.         ng.class="group"
  93.         ng.spacing=0
  94.         ng.horiz=1
  95.          ng.0=string("nick","n")
  96.          ng.1=MakeObj("getnick","popbutton",18)
  97.         sg.2=label("_BanMask","double")
  98.         sg.3=string("banmask","b")
  99.         sg.4=label("_Reasone","double")
  100.         sg.5=string("reasone","r")
  101.         sg.6=label("Ban _Mask","double")
  102.         sg.7="bmg"
  103.         bmg.class="group"
  104.         bmg.horiz=1
  105.          bmg.0="masktype"
  106.          masktype.weight=20
  107.           masktype.class="cycle"
  108.          masktype.entries="nick|user|ip|bad|domain"
  109.          bmg.1=hspace()
  110.  
  111.        mgroup.1 = balance()
  112.  
  113.        mgroup.2="bg"
  114.         bg.class="group"
  115.         bg.weight=0
  116.         bg.innerleft=0
  117.         bg.innerright=0
  118.         bg.innertop=0
  119.         bg.innerbottom=0
  120.         bg.spacing=0
  121.         bg.columns=2
  122.         call child("bg",button("whois","_Whois"))
  123.         call child("bg",button("UInfo","_UInfo"))
  124.         call child("bg",button("op","_Op"))
  125.         call child("bg",button("deop","_DeOp"))
  126.         call child("bg",button("kick","_Kick"))
  127.         call child("bg",button("ban","Ban"))
  128.         call child("bg",button("tban","_TBan"))
  129.         call child("bg",button("kban","_KBan"))
  130.         call child("bg",hvspace())
  131.  
  132.     res=NewObj("APPLICATION","APP")
  133.     if res~=0 then call err(res)
  134.  
  135.     call Notify("MWIN","CLOSEREQUEST",1,"APP","RETURNID","QUIT")
  136.  
  137.     call Notify("nick","newcontents","everytime","APP","setvar","GLOBAL.NICK")
  138.     call Notify("reasone","newcontents","everytime","APP","setvar","GLOBAL.REASONE")
  139.     call Notify("banmask","newcontents","everytime","APP","setvar","GLOBAL.BANMASK")
  140.     call Notify("reasone","newcontents","everytime","APP","setvar","GLOBAL.REASONE")
  141.     call Notify("masktype","active","everytime","APP","setvar","GLOBAL.MASKTYPE")
  142.  
  143.     call Notify("quit","pressed",0,"app","returnid")
  144.     call Notify("getnick","pressed",0,"app","returnid")
  145.     call Notify("masktype","active","everytime","app","returnid")
  146.     call Notify("op","pressed",0,"app","returnid")
  147.     call Notify("whois","pressed",0,"app","returnid")
  148.     call Notify("deop","pressed",0,"app","returnid")
  149.     call Notify("kick","pressed",0,"app","returnid")
  150.     call Notify("ban","pressed",0,"app","returnid")
  151.     call Notify("kban","pressed",0,"app","returnid")
  152.     call Notify("tban","pressed",0,"app","returnid")
  153.     call Notify("kruser" ,"pressed",0,"app","returnid")
  154.  
  155.     return
  156. /***********************************************************************/
  157. halt:
  158. break_c:
  159.     exit
  160. /**************************************************************************/
  161. whois: procedure expose global.
  162.     if global.nick=="" then return
  163.     "RAW WHOIS" global.nick
  164.     return
  165. /**************************************************************************/
  166. UInfo: procedure expose global.
  167.     if global.nick=="" then return
  168.     "RAW ctcp UINFO" global.nick
  169.     return
  170. /**************************************************************************/
  171. op: procedure expose global.
  172.     if global.nick=="" then return
  173.     "SAY /OP" global.nick
  174.     return
  175. /**************************************************************************/
  176. deop: procedure expose global.
  177.     if global.nick=="" then return
  178.     "SAY /DEOP" global.nick
  179.     return
  180. /**************************************************************************/
  181. kick: procedure expose global.
  182.     if global.nick=="" then return
  183.     r=global.reasone
  184.     if r=="" then r="Goodbye honey"
  185.     "SAY /KICK" global.nick r
  186.     return
  187. /**************************************************************************/
  188. ban: procedure expose global.
  189.     if global.nick=="" | global.banMask="" then return
  190.     "SAY /BAN" global.banMask
  191.     return
  192. /**************************************************************************/
  193. kban: procedure expose global.
  194.     if global.nick=="" | global.banMask="" then return
  195.     if a="" then return
  196.     "SAY /DEOP" global.nick
  197.     "SAY /BAN" global.banMask
  198.     call kick
  199.     return
  200. /**************************************************************************/
  201. tban: procedure expose global.
  202.     if global.nick=="" | global.banMask="" then return
  203.     call kban
  204.     "SAY /RX rexx/authpunish" global.ch global.banMask 60
  205.     return
  206. /**************************************************************************/
  207. kruseIT: procedure expose global.
  208.     if global.nick=="" then return
  209.     "SAY /RX kruser" global.nick
  210.     return
  211. /**************************************************************************/
  212. selected: procedure expose global.
  213. parse arg n
  214.     if n=="" then do
  215.         "GETSELECTEDUSER"
  216.         if rc==5 then return
  217.         global.nick=result
  218.     end
  219.     else global.nick=n
  220.     call set("nick","contents",global.nick)
  221.     global.banMask=makeMask()
  222.     call set("banmask","contents",global.banMask)
  223.     return
  224. /**************************************************************************/
  225. syntax:
  226.     "ECHO" rc sigl
  227.     exit
  228. /**************************************************************************/
  229. makeMask: procedure expose global.
  230.     "USERHOST" global.nick
  231.     if rc==5 then return ""
  232.     u=result
  233.     parse var u user"@"rest
  234.     if pos(left(user,1),"~-")~=0 then parse var user +1 user
  235.     select
  236.         when global.MaskType==0 then do
  237.             mask="*"global.nick"*!*@*"
  238.             return mask
  239.         end
  240.         when global.MaskType==1 then do
  241.             mask="*!*"user"*@*"
  242.             return mask
  243.         end
  244.         when global.MaskType==2 then do
  245.             mask="*!*@"rest
  246.             return mask
  247.         end
  248.         when global.MaskType==3 then do
  249.             if IsDotAddr(rest) then return "*!*@"rest
  250.             mask="*!*@"
  251.             do i=1 to length(rest)
  252.                 if DataType(substr(rest,i,1),"N") then do
  253.                     mask=mask||"*"
  254.                     do while DataType(substr(rest,i,1),"N");i=i+1;end
  255.                 end
  256.                 mask=mask||substr(rest,i,1)
  257.             end
  258.             return mask
  259.         end
  260.         when global.MaskType==4 then do
  261.             if IsDotAddr(rest) then do
  262.                 parse var rest p1"."p2"."
  263.                 mask="*!*@"p1"."p2".*"
  264.             end
  265.             else do
  266.                 p=LastPos(".",rest)
  267.                 mask="*!*@*."right(rest,length(rest)-p)
  268.             end
  269.             return mask
  270.         end
  271.         otherwise nop
  272.     end
  273.     return u
  274. /**************************************************************************/
  275.