-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsympa.rb
38 lines (30 loc) · 1016 Bytes
/
sympa.rb
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
["rubygems", "mechanize"].each {|w| require w }
class Sympa
def initialize(epost, pass, list, inst)
# Going into the page
@maillist = list; @domain = inst;
@agent = Mechanize.new
@page = @agent.get('https://sympa.uio.no/'+@domain+'/info/'+@maillist)
# get the login form, fill and submit
f = @page.forms.first
f.email = epost
f.passwd = pass
@page = @agent.submit f
end
def addUser(subscribers)
# Navigating to the right place
@page = @agent.get '/'+@domain+'/admin/'+@maillist
@page = @agent.get '/'+@domain+'/review/'+@maillist
# find the form and fill it out for each new subscriber
subscribers.each do |p|
f = @page.forms[5]
f.email = p
@page = @agent.submit f
end
end
end
## Eksempler
# s = Sympa.new('[email protected]', :ditt_passord, 'cyb-aktiv', 'ifi.uio.no')
## Legge til en bruker i liste
## legg merke til at her skal det være et array :)