-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroupMe.py
More file actions
31 lines (25 loc) · 1.05 KB
/
GroupMe.py
File metadata and controls
31 lines (25 loc) · 1.05 KB
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
import requests, json, logging, os, re, string, array
from pprint import pprint
import collections.abc
import collections.abc
accesstoken = ''
botid = ''
groupid = ''
payload = {"bot_id":botid, "text":"Hello, you executed the program!"}
getfunction = '/groups/' + groupid + '/messages'
postfunction = '/bots/post'
url = 'https://api.groupme.com/v3'
messagestosearch = 20 #How many messages to search
findword = 'Test' #The requested word to find
g = requests.get(url + getfunction + '?token=' + accesstoken, messagestosearch)
lod = json.loads(g.text)
x = 0
itercount = 0
while x <= messagestosearch:
if (lod['response']['messages'][x]['sender_type']) != 'bot':
if findword.lower() in (lod['response']['messages'][x]['text']).lower():
itercount = itercount + 1
x += 1
if x == messagestosearch:
break
requests.post(url + postfunction, {"bot_id":botid, "text":"I see " + str(itercount) + " case-insensitive instances of the word you requested, " + '\"' + findword + '\".'}) #Posts the response to chat