1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
-
|
!
-
|
!
-
|
|
|
|
-
-
|
|
|
-
|
!
!
| #include "hspsock.as"
#ifndef __MOD_IRC__
#define __MOD_IRC__
#module "irc"
#deffunc ircInit str server, int port ,str name
sockopen 0, server, port
if (stat != 0) {
return stat
}
_ircSendMsg "USER", "gokiburi _ _ Gokiburiv0"
_ircSendMsg "NICK", name
_server = server
_name = name
_channel= ""
_loggedIn = 1
_data = ""
return
#deffunc ircLoginChannel str channel
_channel = channel
_msg = channel
_ircSendMsg "JOIN", _msg
_loggedIn = 0
return stat
#deffunc ircMes str msg
_msg = strf("%s :%s", _channel, msg)
_ircSendMsg "PRIVMSG", _msg
mes _channel
return stat
#deffunc _ircSendMsg str msg, str val
sockput "" +msg + " " + val + "\n", 0
return stat
#deffunc ircLogoutChannel
if (_loggedIn) {
return -1
}
_msg = _channel
_ircSendMsg "PART", _msg
return
#deffunc ircTerm
sockclose 0
return
#deffunc ircGetMessages
sockcheck 0
if (_procEnabel) {
sdim _data, 1025
mref _data, 65
sockget _data, 1024, 0
gosub _proc
} else {
if (stat == 0) {
sdim _data, 1025
sockget _data, 1024, 0
return _data
} else {
return -1
}
}
return
#deffunc ircSetMsgProc var proc
_proc = proc
_procEnable = 1
return
#deffunc ircSendPong str ping
_ircSendMsg "PONG", ping
return
#global
#endif
|