~grfgguvf/+junk/ircd-veto

« back to all changes in this revision

Viewing changes to ircparse.erl

  • Committer: me
  • Date: 2008-11-03 11:18:30 UTC
  • Revision ID: me-20081103111830-ryia2f5ady1tqhyv
_

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-module(ircparse).
 
2
-export([p/1]).
 
3
 
 
4
p(Line) ->
 
5
  Tok = tokens(Line),
 
6
  if
 
7
    string:equal(string:to_lower(lists:nth(1, Tok)), "nick") ->
 
8
      %%% FIXME Crap, all those o(n) functions probably can't be used in ifs
 
9
      {nick, lists:nth(2, Tok)};
 
10
    Else ->
 
11
      {unknown, Else}
 
12
  end.
 
13
 
 
14
tokens(Line) ->
 
15
  case string:str(Line, " :") of
 
16
    0 ->
 
17
      string:tokens(Line, " ");
 
18
    MsgStart ->
 
19
      [string:tokens(string:substr(Line, 1, MsgStart), " "),
 
20
        string:substr(Line, MsgStart+2)]
 
21
  end.
 
22