-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroupme.py
65 lines (47 loc) · 1.31 KB
/
groupme.py
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
import sys, config
from datetime import datetime
from threading import Timer
from groupy.client import Client
#### AUTH ####
def GetAllGroups():
token = config.GROUPME_ACCESS_TOKEN
client = Client.from_token(token)
all_groups = client.groups.list()
return all_groups
def GetInput(n):
inp = input("Pick the number of the group you want: ")
try:
inp = int(inp)
except ValueError:
print("That is not an Integer.")
GetInput()
if inp <= 0 or inp > n:
print("That Number is not within range.")
GetInput()
else:
return inp
def GetGroup(list_of_groups):
group_dict = {}
n = 1
for group in list_of_groups:
group_dict[n] = group.name
print(str(n) + ': ' + group.name)
n += 1
group_num = GetInput(n - 1)
for group in list_of_groups:
if group.name == group_dict[group_num]:
selected_group = group
break
return selected_group
def MessageGroup(group, message):
group.post(message)
all_groups = GetAllGroups()
group = GetGroup(all_groups)
# print(group)
# SEND MESSAGE EVERY DAY
# x = datetime.today()
# y = x.replace(day=x.day+1, hour=10, minute=0, second=0, microsecond=0)
# delta_t = y-x
# secs = delta_t.seconds+1
# t = Timer(secs, print('hello'))
# t.start()